POJ1833 排列
[cpp]
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
//Accepted 168K 454MS C++
using namespace std;
int num[1024+10];
int main()
{
int T, n;
int p;
scanf("%d", &T);
while(T--) {
scanf("%d%d", &n, &p);
for(int i = 0; i < n; i++) {
scanf("%d", &num[i]);
} www.zzzyk.com
while(p--) {
if(next_permutation(num, num+n) == 0) {
sort(num, num+n);
} www.zzzyk.com
}
for(int i = 0; i < n-1; i++) {
printf("%d ", num[i]);
}
printf("%d\n", num[n-1]);
}
return 0;
}
http://poj.org/problem?id=1833
补充:软件开发 , C++ ,