結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー |
![]() |
提出日時 | 2018-05-18 22:30:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,226 bytes |
コンパイル時間 | 1,721 ms |
コンパイル使用メモリ | 168,148 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 13:23:36 |
合計ジャッジ時間 | 2,178 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = __int128_t; Int abs128(Int val){return val<0?-val:val;} ostream &operator<<(ostream &os,Int val){ if(ostream::sentry(os)){ __uint128_t tmp=abs128(val); char buf[64]; char *d=end(buf); do{ --d; *d=char(tmp%10+'0'); tmp/=10; }while(tmp); if(val<0) *--d='-'; Int len=end(buf)-d; if(os.rdbuf()->sputn(d,len)!=len){ os.setstate(ios_base::badbit); } } return os; } istream &operator>>(istream &is,Int &val){ string s; is>>s; val=0; for(Int i=0;i<(Int)s.size();i++) if(isdigit(s[i])) val=val*10+s[i]-'0'; if(s[0]=='-') val*=-1; return is; } //INSERT ABOVE HERE signed main(){ Int n; cin>>n; if(n==0){ cout<<1<<endl; cout<<0<<endl; return 0; } if(n==1){ cout<<2<<endl; cout<<1<<" "<<1<<endl; return 0; } for(Int j=2;j<=30;j++){ Int y=j*(j-1)/2; if(n%y) continue; Int z=n/y,cnt=j; while(z%2==0) z>>=1,cnt++; if(z!=1) continue; z=n/y; cout<<cnt<<endl; for(Int i=0;i<j;i++){ if(i) cout<<" "; cout<<1; } while(z!=1){ cout<<" "<<0; z>>=1; } cout<<endl; return 0; } return 0; }