#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template void chmin(T &t, const T &f) { if (t > f) t = f; } template void chmax(T &t, const T &f) { if (t < f) t = f; } constexpr int MAX_L = 592; constexpr int MAX_N = 300001; bitset dp[MAX_L]; int N; int L; char ans[MAX_L + 1]; int main() { dp[0][0] = 1; for (int i = 0; i < MAX_L; ++i) { for (int j = 1; i + j < MAX_L; ++j) { dp[i + j] |= dp[i] << (j * j); } } /* bitset sum; for (int i = 0; i < MAX_L; ++i) { sum |= dp[i]; } assert(sum.all()); //*/ for (; ~scanf("%d", &N); ) { for (L = 0; !dp[L][N]; ++L) {} cerr<<"L = "<= 0 && dp[L - i][n]) { ans[i] = '0'; now += level * level; last = 0; level = 1; } else { ans[i] = '1'; last = 1; ++level; } } else { bool ok = false; for (int j = i + 1; j <= N; ++j) { const int n = N - now - (level + (j - i)) * (level + (j - i)); ok = ok || (n >= 0 && dp[L - j][n]); } if (ok) { ans[i] = '0'; last = 0; ++level; } else { ans[i] = '1'; now += level * level; last = 1; level = 1; } } } ans[L] = '\0'; puts(ans); } return 0; }