#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = mod * mod; typedef pair P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef pair LP; typedef vector vec; typedef long double ld; typedef pair LDP; const ld eps = 1e-5; bool memo[300001][2]; string res[300001][2]; string thmin(string &a, string &b) { if (a.size() < b.size())return a; else if (a.size() > b.size())return b; else { return min(a, b); } } string dfs(int n,int cur) { if (n == 0) { return ""; } if (memo[n][cur])return res[n][cur]; memo[n][cur] = true; int len = 1; string ret; string al; int nw = cur; while (len*len <= n) { al.push_back('0' + nw); nw ^= 1; int tid = cur; if (len % 2 == 0)tid ^= 1; int to = n - len * len; string nex = al + dfs(to, tid); if (ret == "")ret = nex; else { ret = thmin(ret, nex); } len++; } return res[n][cur] = ret; } void solve() { int n; cin >> n; cout << dfs(n, 0) << endl; return; string ans; int cur = 0; vector od,ev; while (n > 0) { int k = sqrt(n + 0.1); cout << k << endl; if (k % 2)od.push_back(k); else ev.push_back(k); //v.push_back(k); n -= k * k; /*rep(i, k) { ans.push_back('0'+cur); cur ^= 1; } cur ^= 1; n -= k * k;*/ } sort(od.begin(), od.end()); rep(i, od.size()) { rep(j, od[i]) { if (j % 2 == 0)ans.push_back('0'); else ans.push_back('1'); } } sort(ev.begin(), ev.end()); int l = 0, r = (int)ev.size() - 1; while (l <= r) { rep(j, ev[r]) { if (j % 2 == 0)ans.push_back('0'); else ans.push_back('1'); } r--; if (l > r)break; rep(j, ev[l]) { if (j % 2 == 0)ans.push_back('1'); else ans.push_back('0'); } l++; } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(5); //init(); solve(); //cout << "finish" << endl; //stop return 0; }