#include <bits/stdc++.h> #define I_can_AK int main using namespace std;

using uint = unsigned int; using ll = long long; using ull = unsigned long long; using i128 = __int128; using u128 = unsigned __int128; using vi = vector; using vll = vector; using pii = pair<int, int>; using pll = pair<ll, ll>; using vst = vector;

const int MAXN = 1e6 + 5;

void Solve(){ int n,m; cin >> n >> m; vectorweight(n); weight[0]=1; for(int i =1; i < n;i++){ weight[i]=weight[i-1]*(n-i)/i; } vectornm(n); for(int i =0; i < n;i++){ nm[i]=i+1; } do{ int sum=0; for(int i =0; i < n;i++){ sum+=nm[i]*weight[i]; } if(sum==m){ for(int i =0; i < n;i++){ cout << nm[i] ; if(i<n-1){ cout << " ";} } cout << endl; return ; } } while(next_permutation(nm.begin(),nm.end()));

return ;

}

I_can_AK(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); int _ = 1; //std::cin >> ; while(--) Solve(); return 0; }

  1. 记住杨辉三角公式就行