标签:poj1833
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 16460 | Accepted: 6596 |
Description
Input
Output
Sample Input
3 3 1 2 3 1 3 1 3 2 1 10 2 1 2 3 4 5 6 7 8 9 10
Sample Output
3 1 2 1 2 3 1 2 3 4 5 6 7 9 8 10
Source
#include <stdio.h> #include <algorithm> using std::next_permutation; int arr[1028], k; int main() { int n, i, t; scanf("%d", &t); while(t--){ scanf("%d%d", &n, &k); for(i = 0; i < n; ++i) scanf("%d", &arr[i]); while(k--) next_permutation(arr, arr + n); for(i = 0; i < n; ++i) if(i != n - 1) printf("%d ", arr[i]); else printf("%d\n", arr[i]); } return 0; }
标签:poj1833
原文地址:http://blog.csdn.net/chang_mu/article/details/38755999