Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID:hsg2
- TASK:kimbits
- LANG:C++11
- */
- #include<bits/stdc++.h>
- using namespace std;
- int dp[50][50] , n , L , K;
- int calc(int x , int bits){
- if(bits > L) return 0;
- if(x == n+1) return 1;
- int &ret = dp[x][bits]; if(ret!=-1) return ret;
- ret = calc(x+1 , bits) + calc(x+1 , bits+1);
- return ret;
- }
- string sol;
- void find_sol(int x , int bits){
- if(x==n+1) return;
- if(calc(x+1 , bits) >= K) {
- sol+="0";
- find_sol(x+1 , bits);
- }
- else{
- K-=calc(x+1 , bits);
- sol+="1";
- find_sol(x+1 , bits+1);
- }
- }
- int main(){
- freopen("kimbits.in","r",stdin);
- freopen("kimbits.out","w",stdout);
- memset(dp , -1 , sizeof(dp));
- cin>>n>>L>>K;
- find_sol(1 , 0);
- cout<<sol<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement