题意:求接下来的第k个排列
思路:next_permutation,书上有实现方法
#include <cstdio>
#include <algorithm>
using namespace std;
int t, n, q, a[1040];
int main()
{
scanf("%d", &t);
while (t --)
{
scanf("%d%d", &n, &q);
for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
while (q --) next_permutation(a, a+n);
for (int i = 0; i < n-1; ++ i) printf("%d ", a[i]);
printf("%d\n", a[n-1]);
}
}