30分求助!!!!
查看原帖
30分求助!!!!
946650
qiuborui楼主2023/10/17 08:57
#include<bits/stdc++.h>
using namespace std;
bool t[70];
int main(){
    long long n,k,l,r,cnt,tot;
    cin>>n>>k;
    l=0,r=tot=pow(2,n)-1,cnt=0;
    while(l<r){
        long long mid=(l+r)>>1;
        if(k>mid){
            t[++cnt]=1,k=(tot-k);
        }
        else{
            t[++cnt]=0;
        }
        r=mid;
        tot>=1;
    }
    for(long long i=1;i<=n;i++) cout<<t[i];
    return 0;
}
2023/10/17 08:57
加载中...