1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #include<bits/stdc++.h> using namespace std;
unsigned long long n, k, ans=0; bool a[100];
int main(){ cin>>n>>k; while(n){ if(k<(1ull<<(n-1))){ a[n--]=0; cout<<0; k=k&((1ull<<n)-1); }else{ a[n--]=1; cout<<1; k=k&((1ull<<n)-1); k=((1ull<<n)-1)-k; } } cout<<endl; return 0; }
|