蒟蒻90pts求调教
查看原帖
蒟蒻90pts求调教
416242
New_hope楼主2023/10/10 20:04

Wa #15 #16

#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;

bool t[70];
signed main() {

    ull n,k,l,r,cnt,tot;
    scanf("%llu %llu",&n,&k);
    l = 0, r = tot = pow(2,n) - 1, cnt = 0;
    // cout << r << endl;
    while(l < r) {
        ull mid = (l + r) >> 1;
        if(k > mid) {
            t[++cnt] = 1, k = (tot - k);
        }
        else {
            t[++cnt] = 0;
        }
        r = mid;
        tot >>= 1;
    }
    for(ull i = 1; i <= n; i ++) cout << t[i];
    return 0;
}
2023/10/10 20:04
加载中...