https://atcoder.jp/contests/abc202/tasks/abc202_d
思路:后往前考虑当前位取不取1,然后取得话我要知道这时候放了1,然后这个用了多少的部分用dp求。
dp[i][j]:到前i个且有j个1的总数。考虑第i位是1还是0
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=70;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL dp[maxn][maxn];
void pre(){
for(LL i=0;i<maxn;i++){
for(LL j=0;j<=i;j++){
if(!j) dp[i][j]=1;
else dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
}
}
}
int main(void){
cin.tie(0);std::ios::sync_with_stdio(false);
pre();
LL a,b,k;cin>>a>>b>>k;
LL num=b;
for(LL i=a+b;i>=1;i--){
if(num>0&&dp[i-1][num]<k){
cout<<"b";
k-=dp[i-1][num];
num--;
}
else cout<<"a";
}
cout<<"\n";
return 0;
}