#include #include typedef long long int ll; typedef long double ld; using namespace std; using namespace atcoder; #define inf 1010000000 #define llinf 1001000000000000000ll #define pi 3.141592653589793238 #define rep(i, n) for(ll i = 0; i < (n); i++) #define rep1(i, n) for(ll i = 1; i <= (n); i++) #define rep2(i,l,r) for(ll i = (l); i < (r); i++) #define per(i, n) for(ll i = (n)-1; i >= 0; i--) #define each(x, v) for (auto&& x : v) #define rng(a) a.begin(),a.end() #define fi first #define se second #define pb push_back #define eb emplace_back #define pob pop_back #define st string #define sz(x) (int)(x).size() #define mems(x) memset(x, -1, sizeof(x)); #define pcnt __builtin_popcountll #define _GLIBCXX_DEBUG #define dame { puts("-1"); return 0;} #define yes { puts("Yes"); return 0;} #define no { puts("No"); return 0;} #define ret(x) { cout<<(x)< inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false;} template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false;} // 仮マクロ 便利だったら昇格 #define dump(x) { cout << #x << " = " << (x) << endl;} #define bit(n) (1LL<<(n)) #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end()) template inline T in(){ T x; cin >> x; return (x);} #define vcin(x,n) {for(ll loop=0; loop<(n); loop++) cin>>x[loop];} // ここまで仮マクロ // srand((unsigned)time(NULL)); rand()を用いる際にmainの頭に置く // clock()/CLOCKS_PER_SEC 秒数を知りたいときに用いる #define mod 998244353 using mint = modint998244353; /* #define mod 1000000007 using mint = modint1000000007; */ vector dx={1,0,-1,0}; vector dy={0,1,0,-1}; using pl = pair; using ppl = pair; using V = vector; using Graph = vector>; // G.assign(n, vector()); グローバル変数にGを置く時に置く // 関数を置くのはここ以下 template struct edge { int src, to; T cost; edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {} edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; template using Edges = vector>; template using WeightedGraph = vector>; using UnweightedGraph = vector>; // Input of (Unweighted) Graph UnweightedGraph graph(int N, int M = -1, bool is_directed = false, bool is_1origin = true) { UnweightedGraph g(N); if (M == -1) M = N - 1; for (int _ = 0; _ < M; _++) { int x, y; cin >> x >> y; if (is_1origin) x--, y--; g[x].push_back(y); if (!is_directed) g[y].push_back(x); } return g; } // Input of Weighted Graph template WeightedGraph wgraph(int N, int M = -1, bool is_directed = false, bool is_1origin = true) { WeightedGraph g(N); if (M == -1) M = N - 1; for (int _ = 0; _ < M; _++) { int x, y; cin >> x >> y; T c; cin >> c; if (is_1origin) x--, y--; g[x].emplace_back(x, y, c); if (!is_directed) g[y].emplace_back(y, x, c); } return g; } // Input of Edges template Edges esgraph(int N, int M, int is_weighted = true, bool is_1origin = true) { Edges es; for (int _ = 0; _ < M; _++) { int x, y; cin >> x >> y; T c; if (is_weighted) cin >> c; else c = 1; if (is_1origin) x--, y--; es.emplace_back(x, y, c); } return es; } // Input of Adjacency Matrix template vector> adjgraph(int N, int M, T INF, int is_weighted = true, bool is_directed = false, bool is_1origin = true) { vector> d(N, vector(N, INF)); for (int _ = 0; _ < M; _++) { int x, y; cin >> x >> y; T c; if (is_weighted) cin >> c; else c = 1; if (is_1origin) x--, y--; d[x][y] = c; if (!is_directed) d[y][x] = c; } return d; } // 一般のグラフのstからの距離!!!! // unvisited nodes : d = -1 vector Depth(const UnweightedGraph &g, int start = 0) { int n = g.size(); vector ds(n, -1); ds[start] = 0; queue q; q.push(start); while (!q.empty()) { int c = q.front(); q.pop(); int dc = ds[c]; for (auto &d : g[c]) { if (ds[d] == -1) { ds[d] = dc + 1; q.push(d); } } } return ds; } // Depth of Rooted Weighted Tree // unvisited nodes : d = -1 template vector Depth(const WeightedGraph &g, int start = 0) { vector d(g.size(), -1); auto dfs = [&](auto rec, int cur, T val, int par = -1) -> void { d[cur] = val; for (auto &dst : g[cur]) { if (dst == par) continue; rec(rec, dst, val + dst.cost, cur); } }; dfs(dfs, start, 0); return d; } // Diameter of Tree // return value : { {u, v}, length } pair, int> Diameter(const UnweightedGraph &g) { auto d = Depth(g, 0); int u = max_element(begin(d), end(d)) - begin(d); d = Depth(g, u); int v = max_element(begin(d), end(d)) - begin(d); return make_pair(make_pair(u, v), d[v]); } // Diameter of Weighted Tree // return value : { {u, v}, length } template pair, T> Diameter(const WeightedGraph &g) { auto d = Depth(g, 0); int u = max_element(begin(d), end(d)) - begin(d); d = Depth(g, u); int v = max_element(begin(d), end(d)) - begin(d); return make_pair(make_pair(u, v), d[v]); } // nodes on the path u-v ( O(N) ) template vector Path(G &g, int u, int v) { vector ret; int end = 0; auto dfs = [&](auto rec, int cur, int par = -1) -> void { ret.push_back(cur); if (cur == v) { end = 1; return; } for (int dst : g[cur]) { if (dst == par) continue; rec(rec, dst, cur); if (end) return; } if (end) return; ret.pop_back(); }; dfs(dfs, u); return ret; } template vector dijkstra(WeightedGraph &g, int start = 0) { using P = pair; int N = (int)g.size(); vector d(N, T(-1)); priority_queue, greater

> Q; d[start] = 0; Q.emplace(0, start); while (!Q.empty()) { P p = Q.top(); Q.pop(); int cur = p.second; if (d[cur] < p.first) continue; for (auto dst : g[cur]) { if (d[dst] == T(-1) || d[cur] + dst.cost < d[dst]) { d[dst] = d[cur] + dst.cost; Q.emplace(d[dst], dst); } } } return d; } // edge 型Tの重みが付いた辺 // Edges 型Tの重みが付いた辺のリスト // WeightedGraph 型Tの重みが付いた(有向/無向)グラフ // UnweightedGraph 重みなし(有向/無向)グラフ // graph(N, M(-1の時N-1), bool is_directed = false, bool is_1origin = true) // 重みなしのグラフを標準入力から読み込み、UnweightedGraph型で返す。 // ex) graph(n,,,) であればN頂点の無向木 // wgraph(...) = 有向木 // esgraph,adjgraph = 隣接リスト,隣接行列を返す // - 機能 - ( だいたいO(N) ) // vector Depth(UnweightedGraph g, int s = 0) // sからの最短距離 // vector Depth(weightedGraph g, int s = 0) // (重み付き根つき木限定) sからの距離 // pair, int> Diameter(UnweightedGraph g) // pair, T> Diameter(WeightedGraph g) // 木の直径の両端,長さを返す // vector Path(G &g, int u, int v) // vector Path(G &g, int u, int v) // (両端含む)パスの頂点列を返す // vector dijkstra(g, s = 0) // ダイクストラ法 (O(ElogV)) // 計算量:O(ElogV) // 届かなかったら-1 int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); ll n = in(); vector v; rep1(i,30000){ if(i*i>n) break; v.eb(i*i); } ll m = v.size(); WeightedGraph g(n+1); rep(i,n+1){ rep(j,m){ if(i+v[j]<=n){ g[i].eb(i+v[j],j+1); } } } vector dist = dijkstra(g,0); vector ans; // 使うバイナリ ll now = n; per(i,m){ while(now-v[i]>=0 && dist[now-v[i]] + i + 1 == dist[now]){ ans.eb(i+1); now -= v[i]; } } st s; rep(i,(ll)ans.size()){ rep(j,ans[i]){ if(i%2==0){ s += '0'; }else s += '1'; } } rep(i,(ll)s.size()){ if(i%2==1){ if(s[i]=='0') s[i] = '1'; else s[i] = '0'; } } ret(s); }