http://www.luogu.org/problem/show?pid=1088
求字典序第k小全排列,可以用C++的next_permutation函数
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define ms(i,j) memset(i,j, sizeof i);
using namespace std;
int a[10005];
int main()
{
int n,k;
scanf("%d%d", &n ,&k);
for (int i=1;i<=n;i++) scanf("%d", &a[i]);
while (k--) next_permutation(a+1 ,a+1+n);
for (int i=1;i<=n;i++) printf("%d ", a[i]);
return 0;
}