#include int ri() { int n; assert(scanf("%d", &n) == 1); return n; } int main () { int n = ri(); struct Info { int cost; int one_cost; int odds_min; Info (int cost, int one_cost, int odds_min) : cost(cost), one_cost(one_cost), odds_min(odds_min) {} Info () : cost(1000000000), one_cost(-1), odds_min(1000000000){} }; Info dp[n + 1];// {val, cost} for (int i = 0; i <= n; i++) dp[i] = {1000000000, -1, -1}; dp[n] = {0, 0, 0}; for (int i = n; i >= 0; i--) { for (int j = 0; j * j <= i; j++) { if (dp[i - j * j].cost > dp[i].cost + j) { dp[i - j * j].cost = dp[i].cost + j; dp[i - j * j].one_cost = j; dp[i - j * j].odds_min = std::min(dp[i].odds_min, j % 2 ? j : 1000000000); } else if (dp[i - j * j].cost == dp[i].cost + j) { if (dp[i - j * j].odds_min > std::min(dp[i].odds_min, j % 2 ? j : 1000000000)) { dp[i - j * j].odds_min = std::min(dp[i].odds_min, j % 2 ? j : 1000000000); dp[i - j * j].one_cost = j; } } } } std::vector rens; int cur = 0; while (cur < n) { rens.push_back(dp[cur].one_cost); cur += dp[cur].one_cost * dp[cur].one_cost; } std::sort(rens.begin(), rens.end()); assert(cur == n); /* for (auto i : rens) std::cerr << i << " "; std::cerr << std::endl;*/ std::deque odds, evens; for (auto i : rens) (i % 2 ? odds : evens).push_back(i); std::string res; for (auto i : odds) { if (!res.size()) res.push_back('0'); else res.push_back(res.back()); for (int j = 0; j + 1 < i ; j++) res.push_back(!(res.back() - '0') + '0'); } int cnt = 0; while (evens.size()) { int v; if (cnt++ % 2 == 0) { v = evens.back(); evens.pop_back(); } else { v = evens.front(); evens.pop_front(); } if (!res.size()) res.push_back('0'); else res.push_back(res.back()); for (int j = 0; j + 1 < v; j++) res.push_back(!(res.back() - '0') + '0'); } std::cout << res << std::endl; return 0; }