//yukicoder@cpp17 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; const ll MOD = 998244353; const ll MODx = 1000000007; const int INF = (1<<30)-1; const ll LINF = (1LL<<62LL)-1; const double EPS = (1e-10); P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}}; P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}; template vector make_vector(size_t a, T b) { return vector(a, b); } template auto make_vector(size_t a, Ts... ts) { return vector(a, make_vector(ts...)); } /* 確認ポイント cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる 計算量は変わらないが楽できるシリーズ min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる */ /* comment outed because can cause bugs __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } */ // 整数型を取得することを想定 template T CeilExactSqrt(int c, T x){ T mn = 0; T mx = x; while(mx-mn > 1){ T ce = (mn+mx)/2; T nw = 1; for(int i = 0; c > i; i++){ if(x/ce < nw){ mx = ce; break; } nw *= ce; if(i+1 == c && x == nw){ mx = ce; } } if(mx != ce)mn = ce; } return mx; } template T FloorExactSqrt(int c, T x){ T mn = 0; T mx = x; while(mx-mn > 1){ T ce = (mn+mx)/2; T nw = 1; for(int i = 0; c > i; i++){ if(x/ce < nw){ mx = ce; break; } nw *= ce; } if(mx != ce)mn = ce; } return mn; } struct d{ int n, i; bool operator<(const d a)const{ if(n == a.n)return i < a.i; return n < a.n; } }; map X; int b(int n, int i){ if(n == 0 || i == 1){ X[{n,i}] = n; return n; } else{ int mn = n+1; int mnj = -1; for(int j = 0; n/(i*i) >= j; j++){ int x = (b(n-j*(i*i), i-1)+j*i); if(x < mn){ mn = x; mnj = j; } } X[{n,i}] = mnj; return mn; } } void zig(int x, char s){ for(int i = 0; x > i; i++){ cout << s; s = (s == '0' ? '1' : '0'); } } int main(){ long long n;cin>>n; if(n == 1){ cout << "0" << endl; return 0; } b(n, FloorExactSqrt(2, n)); int nwn = n; int i = FloorExactSqrt(2, n); vector Z; while(X.find({nwn, i}) != X.end()){ for(int j = 0; X[{nwn, i}] > j; j++){ Z.push_back(i); } //cout << nwn << " " << i << " " << X[{nwn, i}] << endl; nwn = nwn-X[{nwn, i}]*(i*i); i--; } sort(Z.begin(), Z.end()); char next = '0'; deque Zp; for(int j = 0; Z.size() > j; j++){ if(Z[j]%2 == 1){ zig(Z[j], next); }else{ Zp.push_back(Z[j]); } } bool back = true; while(Zp.size()){ if(back){ auto z = Zp.back();Zp.pop_back(); zig(z, '0'); }else{ auto z = Zp.front();Zp.pop_front(); zig(z, '1'); } back ^= 1; } cout << endl; return 0; }