結果
問題 |
No.550 夏休みの思い出(1)
|
ユーザー |
![]() |
提出日時 | 2017-07-28 23:23:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,803 bytes |
コンパイル時間 | 2,114 ms |
コンパイル使用メモリ | 169,228 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 05:02:56 |
合計ジャッジ時間 | 4,222 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 WA * 26 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } using Int = __int128; Int sqrt(Int A){ Int L = 0, R = LLONG_MAX; while(L+1<R){ Int M=(L+R)/2; if(M*M<=A) L=M; else R=M; } return L; } int a,b,c; Int A,B,C,P,Q; Int calc(Int x){ return x*x*x+A*x*x+B*x+C; } Int calc2(Int x){ return x*x+P*x+Q; } signed main(){ cin>>a>>b>>c; A=a;B=b;C=c; set<Int> ans; for(Int i=-1e6;i<1e6;i++){ if(calc(i)==0) ans.insert(i); } if((int)ans.size()<3){ Int k=*ans.begin(); P=A+k,Q=k*(A+k); { Int L=INT_MIN,R=-P/2; for(Int i=-1000;i<1000;i++) if(calc(R+i)==0) ans.insert(R+i); while(L+1<R){ Int M=(L+R)/2; if(calc(M)>=0) L=M; else R=M; for(Int i=-1000;i<1000;i++) if(calc(R+i)==0) ans.insert(R+i); } for(Int i=-1000;i<1000;i++) if(calc(R+i)==0) ans.insert(R+i); } { Int L=INT_MIN,R=-P/2; for(Int i=-1000;i<1000;i++) if(calc(R+i)==0) ans.insert(R+i); while(L+1<R){ Int M=(L+R)/2; if(calc(M)<=0) L=M; else R=M; for(Int i=-1000;i<1000;i++) if(calc(R+i)==0) ans.insert(R+i); } for(Int i=-1000;i<1000;i++) if(calc(R+i)==0) ans.insert(R+i); } } bool flg=0; for(Int i:ans){ if(flg) cout<<" "; cout<<i; flg=1; } cout<<endl; return 0; }