hdu_1027(好吧。。。牛。。。next_permutation也可以水过)

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 const int N = 1010;
 6 int tm[N];
 7 int main()
 8 {
 9     int n, m;
10     while (~scanf("%d%d", &n, &m))
11     {
12         for (int i = 1; i <= n; i++) {
13             tm[i] = i;
14         }
15         m--;
16         while (m--) {
17             next_permutation(tm + 1, tm + n + 1);
18         }
19         for (int i = 1; i < n; i++)
20             printf("%d ", tm[i]);
21         printf("%d
", tm[n]);
22     }
23 }