//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} const size_t N = 3e5+10; //head int n; int dp[N]; vi G[N]; bitset bits; string ans; bool comp(int i, int j) { return (i^j)&1 ? (i&1)==1 : i&1 ? ij; } int dfs1(int x) { if(x == 0) { return 0; } if(dp[x]) return dp[x]; int &res = dp[x] = INF; rep(i, int(sqrt(x)+0.001)) { int k = i+1; chmin(res, dfs1(x-k*k) + k); } return res; } void dfs2(int x) { if(!x) return; if(bits.test(x)) return; rep(i, int(sqrt(x)+0.001)) { int k = i+1; if(dp[x] == dp[x-k*k] + k) { G[x-k*k].emplace_back(k); dfs2(x-k*k); } } bits.set(x); } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; dfs1(n); dfs2(n); //rep(i, n+1) cout << dp[i] << endl; /* rep(i, n+1) { cout << G[i].size() << endl; rep(j, G[i].size()) { cout << G[i][j] << (j == G[i].size()-1?'\n':' '); } } */ int now = 0; while(now != n) { sort(all(G[now]), comp); if(ans.empty() or ans[ans.size()-1] == '0') { rep(i, G[now][0]) { ans += char('0'+(i&1)); } now += G[now][0]*G[now][0]; } else { rep(i, G[now][G[now].size()-1]) { ans += char('1'-(i&1)); } now += G[now][G[now].size()-1]*G[now][G[now].size()-1]; } } cout << ans << endl; }