思路:
next_permutation()加个递推组合数随便搞搞就A了…
//By SiriusRen
#include <cstdio>
#include <algorithm>
using namespace std;
int n,C[11][11],sum,f[11];
int main(){
scanf("%d%d",&n,&sum);
for(int i=1;i<=n;i++)C[i][i]=1,f[i]=i;
for(int i=1;i<=n;i++)
for(int j=2;j<=n;j++)
C[i][j]=C[i][j-1]+C[i-1][j-1];
do{
int temp=0;
for(int i=1;i<=n;i++)temp+=C[i][n]*f[i];
if(temp==sum){
for(int i=1;i<=n;i++)printf("%d ",f[i]);
return 0;
}
}while(next_permutation(f+1,f+1+n));
}