rt, 这不科学, 蒟蒻在所有可能的地方都转了ULL, 不应该WA on 20啊?
#include <bits/stdc++.h>
#define rep(a, b, c) for(register int a = b; a <= c; ++ a)
#define Rrep(a, b, c) for(register int a = b; a >= c; -- a)
#define VSCCOM
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 100005, inf = 0x3f3f3f3f;
inline void End() {
#ifdef VSCCOM
puts(""); system("pause");
#endif
exit(0);
}
template<class T> inline T max(T &x, T &y) { return x > y ? x : y; }
template<class T> inline T min(T &x, T &y) { return x < y ? x : y; }
template<class T> inline T abs(T &x) { return x > 0 ? x : -x; }
int n;
ull k;
string dfs(int tn, ull tk) {
if(tn == 1) {
if(tk == 0ULL) return "0";
else return "1";
}
if(tk >= (1ULL << (tn - 1))) return "1" + dfs(tn - 1, (unsigned long long)((1ULL << tn) - (unsigned long long)(tk) - 1ULL));
else return "0" + dfs(tn - 1, (unsigned long long)(tk));
}
int main() {
//while(1) {
cin >> n >> k;
cout << dfs(n, k) << endl;
//}
End();
}
/*
18446744073709551615
n = 4
0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100,
1100, 1101, 1111, 1110, 1010, 1011, 1001, 1000
*/