蒟蒻打了个十分简单的dfs模拟~~(找规律?二进制?不存在的)~~
然后,按照正常来说,ull 存到64次方会变成0. 然而我将其改成龟速幂运算或者快速幂,就不会出现这个错误了?
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
inline ll pow(ll x){
ll a = 1, temp = 2;
for(int i = 1;i <= x; i++){
a *= temp;
}
return a;
}
ll a[100], cnt = 0;
void dfs(ll n, ll k){
if(n == 1){
if(k == 1) a[++cnt] = 1;
else a[++cnt] = 0;
return ;
}
if(k >= (pow(n) / 2) )
dfs(n - 1, (pow(n) - k - 1));
else dfs(n - 1, k);
if(k >= pow(n) / 2) a[++cnt] = 1;
else a[++cnt] = 0;
return ;
}
int main(){
// freopen("hh.txt", "r", stdin);
ll n, k;
cin >> n >> k;
dfs(n, k);
for(int i = cnt;i > 0; i--) printf("%d", a[i]);
return orz;
}