#include using namespace std; //#define int long long //TEMPLATE START---------------8<---------------8<---------------8<---------------8<---------------// typedef long long Int; typedef long long ll; typedef long double ld; typedef pair pii; typedef pair pll; typedef vector vi; typedef vector vl; typedef vector vst; typedef vector vb; typedef vector vld; typedef vector vpii; typedef vector vpll; typedef vector > vvi; const int INF = (0x7FFFFFFFL); const ll INFF = (0x7FFFFFFFFFFFFFFFL); const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const int MOD = 1e9 + 7; const int MODD = 998244353; const string alphabet = "abcdefghijklmnopqrstuvwxyz"; const double PI = acos(-1.0); const double EPS = 1e-9; const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; int dx[9] = { 1, 0, -1, 0, 1, -1, -1, 1, 0 }; int dy[9] = { 0, 1, 0, -1, -1, -1, 1, 1, 0 }; #define ln '\n' #define scnaf scanf #define sacnf scanf #define sancf scanf #define SS(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template void MACRO_VAR_Scan(T& t){cin >> t;}template void MACRO_VAR_Scan(First& first, Rest&...rest){cin >> first;MACRO_VAR_Scan(rest...);} #define SV(type,c,n) vector c(n);for(auto& i:c)cin >> i; #define SVV(type,c,n,m) vector> c(n,vector(m));for(auto& r:c)for(auto& i:r)cin >> i; templateostream &operator<<(ostream &o,const pair&j){o<<"{"<ostream &operator<<(ostream &o,const map&j){o<<"{";for(auto t=j.begin();t!=j.end();++t)o<<(t!=j.begin()?", ":"")<<*t;o<<"}";return o;} templateostream &operator<<(ostream &o,const set&j){o<<"{";for(auto t=j.begin();t!=j.end();++t)o<<(t!=j.begin()?", ":"")<<*t;o<<"}";return o;} templateostream &operator<<(ostream &o,const vector&j){o<<"{";for(int i=0;i<(int)j.size();++i)o<<(i>0?", ":"")< int print(Head&& head){cout << head;print();return 0;} template int print(Head&& head,Tail&&... tail){cout<(tail)...);return 0;} inline int debug(void){cerr << endl; return 0;} template int debug(Head&& head){cerr << head;debug();return 0;} template int debug(Head&& head,Tail&&... tail){cerr<(tail)...);return 0;} template void PA(T &a){int ASIZE=sizeof(a)/sizeof(a[0]);for(int ii=0;ii void PV(T &v){int VSIZE=v.size();for(int ii=0;ii void sankou(bool x,A a,B b){cout<<((x)?(a):(b))<=ll(b);--i) #define RREP(...) _overload3(__VA_ARGS__,RREPI,_RREP,)(__VA_ARGS__) #define EACH(e,v) for(auto& e : v) #define PERM(v) sort((v).begin(),(v).end());for(bool c##p=1;c##p;c##p=next_permutation((v).begin(),(v).end())) #define ADD(a,b) a=(a+ll(b))%MOD #define MUL(a,b) a=(a*ll(b))%MOD inline ll MOP(ll x,ll n,ll m=MOD){ll r=1;while(n>0){if(n&1)(r*=x)%=m;(x*=x)%=m;n>>=1;}return r;} inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}inline ll lcm(ll a,ll b){return a*b/gcd(a,b);}inline ll POW(ll a,ll b){ll c=1ll;do{if(b&1)c*=1ll*a;a*=1ll*a;}while(b>>=1);return c;} template inline bool between(T x,A a,B b) {return ((a<=x)&&(x inline T sqr(T x){return x*x;} template inline bool chmax(A &a,const B &b){if(a inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;} #define tmax(x,y,z) max((x),max((y),(z))) #define tmin(x,y,z) min((x),min((y),(z))) #define PB push_back #define MP make_pair #define MT make_tuple #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define SORT(v) sort((v).begin(),(v).end()) #define RSORT(v) sort((v).rbegin(),(v).rend()) #define EXIST(s,e) (find((s).begin(),(s).end(),(e))!=(s).end()) #define EXISTST(s,c) (((s).find(c))!=string::npos) #define POSL(x,val) (lower_bound(x.begin(),x.end(),val)-x.begin()) #define POSU(x,val) (upper_bound(x.begin(),x.end(),val)-x.begin()) #define GEQ(x,val) (int)(x).size() - POSL((x),(val)) #define GREATER(x,val) (int)(x).size() - POSU((x),(val)) #define LEQ(x,val) POSU((x),(val)) #define LESS(x,val) POSL((x),(val)) #define SZV(a) int((a).size()) #define SZA(a) sizeof(a)/sizeof(a[0]) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMINF(a) memset(a,0x3f,sizeof(a)) #define FILL(a,b) memset(a,b,sizeof(a)) #define UNIQUE(v) sort((v).begin(),(v).end());(v).erase(unique((v).begin(),(v).end()),(v).end()) struct abracadabra{ abracadabra(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); cerr << fixed << setprecision(5); }; } ABRACADABRA; //TEMPLATE END---------------8<---------------8<---------------8<---------------8<---------------// namespace FFT{ using dbl = double; struct num{ dbl x,y; num(){x=y=0;} num(dbl x,dbl y):x(x),y(y){} }; inline num operator+(num a,num b){ return num(a.x+b.x,a.y+b.y); } inline num operator-(num a,num b){ return num(a.x-b.x,a.y-b.y); } inline num operator*(num a,num b){ return num(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x); } inline num conj(num a){ return num(a.x,-a.y); } int base=1; vector rts={{0,0},{1,0}}; vector rev={0,1}; const dbl PI=acosl(-1.0); void ensure_base(int nbase){ if(nbase<=base) return; rev.resize(1<>1]>>1)+((i&1)<<(nbase-1)); rts.resize(1< &a,int n=-1){ if(n==-1) n=a.size(); assert((n&(n-1))==0); int zeros=__builtin_ctz(n); ensure_base(zeros); int shift=base-zeros; for(int i=0;i>shift)) swap(a[i],a[rev[i]>>shift]); for(int k=1;k fa; template vector multiply(const vector &a,const vector &b){ int need=a.size()+b.size()-1; int nbase=0; while((1<(int)fa.size()) fa.resize(sz); for(int i=0;i>1);i++){ int j=(sz-i)&(sz-1); num z=(fa[j]*fa[j]-conj(fa[i]*fa[i]))*r; if(i!=j) fa[j]=(fa[i]*fa[i]-conj(fa[j]*fa[j]))*r; fa[i]=z; } fft(fa,sz); vector res(need); for(int i=0;i; constexpr static ll base = 1000000000; constexpr static ll base_digits = 9; vll a; ll sign; bigint():sign(1){} bigint(ll v){*this=v;} bigint(const string &s){read(s);} void operator=(const bigint &v){ sign=v.sign; a=v.a; } void operator=(ll v){ sign=1; if(v<0) sign=-1,v=-v; for(;v>0;v=v/base) a.push_back(v%base); } bigint operator+(const bigint &v) const{ if(sign==v.sign){ bigint res=v; for(ll i=0,carry=0;i<(ll)max(a.size(),v.a.size())||carry;++i){ if(i==(ll)res.a.size()) res.a.push_back(0); res.a[i]+=carry+(i<(ll)a.size()?a[i]:0); carry=res.a[i]>=base; if(carry) res.a[i]-=base; } return res; } return *this -(-v); } bigint operator-(const bigint &v) const{ if(sign==v.sign){ if(abs()>=v.abs()){ bigint res=*this; for(ll i=0,carry=0;i<(ll)v.a.size()||carry;++i){ res.a[i]-=carry+(i<(ll)v.a.size()?v.a[i]:0); carry=res.a[i]<0; if(carry) res.a[i]+=base; } res.trim(); return res; } return -(v-*this); } return *this+(-v); } void operator*=(ll v){ if(v<0) sign=-sign,v=-v; for(ll i=0,carry=0;i<(ll)a.size()|| carry;++i){ if(i ==(ll)a.size()) a.push_back(0); ll cur=a[i] *(ll)v+carry; carry=(ll)(cur/base); a[i]=(ll)(cur%base); // asm("divl %%ecx" : "=a"(carry),"=d"(a[i]) : "A"(cur),"c"(base)); } trim(); } bigint operator*(ll v) const{ bigint res=*this; res *=v; return res; } friend pair divmod(const bigint &a1,const bigint &b1){ ll norm=base/(b1.a.back()+1); bigint a=a1.abs()*norm; bigint b=b1.abs()*norm; bigint q,r; q.a.resize(a.a.size()); for(ll i=a.a.size()-1;i>=0;i--){ r *=base; r+=a.a[i]; ll s1=r.a.size()<=b.a.size() ? 0 : r.a[b.a.size()]; ll s2=r.a.size()<=b.a.size()-1 ? 0 : r.a[b.a.size()-1]; ll d=((ll)base*s1+s2)/b.a.back(); r-=b*d; while(r<0) r+=b,--d; q.a[i]=d; } q.sign=a1.sign*b1.sign; r.sign=a1.sign; q.trim(); r.trim(); return make_pair(q,r/norm); } bigint operator/(const bigint &v) const{ return divmod(*this,v).first; } bigint operator%(const bigint &v) const{ return divmod(*this,v).second; } void operator/=(ll v){ if(v<0) sign=-sign,v=-v; for(ll i=(ll)a.size()-1,rem=0;i>=0;--i){ ll cur=a[i]+rem *(ll)base; a[i]=(ll)(cur/v); rem=(ll)(cur%v); } trim(); } bigint operator/(ll v) const{ bigint res=*this; res/=v; return res; } ll operator%(ll v) const{ if(v<0) v=-v; ll m=0; for(ll i=a.size()-1;i>=0;--i) m=(a[i]+m *(ll)base)%v; return m*sign; } void operator+=(const bigint &v){ *this=*this+v; } void operator-=(const bigint &v){ *this=*this-v; } void operator*=(const bigint &v){ *this=*this*v; } void operator/=(const bigint &v){ *this=*this/v; } bool operator<(const bigint &v) const{ if(sign!=v.sign) return sign=0;i--) if(a[i]!=v.a[i]) return a[i]*sign(const bigint &v) const{ return v<*this; } bool operator<=(const bigint &v) const{ return !(v<*this); } bool operator>=(const bigint &v) const{ return !(*this=0;i--) res=res*base+a[i]; return res*sign; } friend bigint gcd(const bigint &a,const bigint &b){ return b.isZero() ? a : gcd(b,a%b); } friend bigint lcm(const bigint &a,const bigint &b){ return a/gcd(a,b)*b; } void read(const string &s){ sign=1; a.clear(); ll pos=0; while(pos<(ll)s.size()&&(s[pos]=='-'|| s[pos]=='+')){ if(s[pos]=='-') sign=-sign; ++pos; } for(ll i=s.size()-1;i>=pos;i-=base_digits){ ll x=0; for(ll j=max(pos,i-base_digits+1);j<=i;j++) x=x*10+s[j]-'0'; a.push_back(x); } trim(); } friend istream &operator>>(istream &stream,bigint &v){ string s; stream>>s; v.read(s); return stream; } friend ostream &operator<<(ostream &stream,const bigint &v){ if(v.sign==-1) stream<<'-'; stream<<(v.a.empty()?0:v.a.back()); for(ll i=(ll)v.a.size()-2;i>=0;--i) stream<=new_digits){ res.push_back(signed(cur%p[new_digits])); cur/=p[new_digits]; cur_digits-=new_digits; } } res.push_back((signed)cur); while(!res.empty()&&!res.back()) res.pop_back(); return res; } static vll karatsubaMultiply(const vll &a,const vll &b){ ll n=a.size(); vll res(n+n); if(n<=32){ for(ll i=0;i>1; vll a1(a.begin(),a.begin()+k); vll a2(a.begin()+k,a.end()); vll b1(b.begin(),b.begin()+k); vll b2(b.begin()+k,b.end()); vll a1b1=karatsubaMultiply(a1,b1); vll a2b2=karatsubaMultiply(a2,b2); for(ll i=0;ia,base_digits,nbase_digits); vll b=convert_base(v.a,base_digits,nbase_digits); /* while(a.size()0) c.push_back(0); } res.a=convert_base(res.a,nbase_digits,base_digits); res.trim(); return res; } }; const int MAX_BIT = 1850; void out(int _1, int _2, int _3) { // print(_1, _2, _3); bigint res = 0; REP(i, _1 + _2 + _3) { res *= 2; if (i < _1 || i >= _1 + _2) { res += 1; } } print(res); } signed main() { SS(ll, N); ll tmp = 0; ll M, digit; REP(i, MAX_BIT) { tmp += i * (i - 1) / 2 + 1; if (tmp == N) { print(i + 1); return 0; } if (tmp > N) { digit = i + 1; break; } M = N - tmp; } // 初期状態: 1がdigit個ならんでいる REP(l, 1, digit) { REP(r, l + 1, digit) { int _1 = l; int _2 = r - l; int _3 = digit - r; ll tmp = _3 + (_2 + _3 - 1) * (_1 - 1) + _1 * (_1 - 1) / 2; // print(_1, _2, _3, tmp); if (tmp == M) { out(_1, _2, _3); return 0; } } } // debug(M, digit); }