思路
next_permutation()
拓展题
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
int n, m;
int a[N];
int main()
{
while(cin >> n >> m)
{
for(int i = 1; i <= n; i ++ )
a[i] = i;
while( -- m)
{
next_permutation(a + 1, a + 1 + n);
}
for(int i = 1; i <= n; i ++ )
{
if(i == 1)
cout << a[i];
else
cout << " " << a[i];
}
cout << endl;
}
return 0;
}