简单题
View Code
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define maxn 15
int n, f[maxn], g[maxn], sum;
int cal()
{
int ret = 0;
for (int i = 0; i < n; i++)
ret += f[i] * g[i];
return ret;
}
int main()
{
//freopen("t.txt", "r", stdin);
scanf("%d%d", &n, &sum);
memset(f, 0, sizeof(f));
f[0] = 1;
for (int i = 1; i < n; i++)
{
for (int j = i; j >= 1; j--)
f[j] = f[j] + f[j - 1];
}
for (int i = 0; i < n; i++)
g[i] = i + 1;
while (sum != cal())
next_permutation(g, g + n);
printf("%d", g[0]);
for (int i = 1; i < n; i++)
printf(" %d", g[i]);
putchar('\n');
return 0;
}