#include #include #include using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector dp(N+1,vector(2,1<<30)); vector to(N+1,vector(2,-1)); dp[N][0]=0; dp[N][1]=0; for(int x=N-1;x>=0;x--){ for(int t=0;t<2;t++){ if(t==0){ for(int a=1;x+a*a<=N;a+=2){ if(chmin(dp[x][t],dp[x+a*a][t]+a)){ to[x][t]=a; } } vectorv; for(int a=2;x+a*a<=N;a+=2)v.push_back(a); reverse(all(v)); for(auto a:v){ if(chmin(dp[x][t],dp[x+a*a][1-t]+a)){ to[x][t]=a; } } }else{ for(int a=2;x+a*a<=N;a+=2){ if(chmin(dp[x][t],dp[x+a*a][1-t]+a)){ to[x][t]=a; } } vectorv; for(int a=1;x+a*a<=N;a+=2)v.push_back(a); reverse(all(v)); for(auto a:v){ if(chmin(dp[x][t],dp[x+a*a][t]+a)){ to[x][t]=a; } } } } } int x=0,t=0; while(to[x][t]!=-1){ int a=to[x][t]; x+=a*a; if(a%2==0)t=1-t; for(int i=a-1;i>=0;i--){ if(i%2==t)cout<<0; else cout<<1; } } cout<<"\n"; }