結果
| 問題 | No.550 夏休みの思い出(1) |
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2017-07-28 23:34:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,997 bytes |
| 記録 | |
| コンパイル時間 | 1,504 ms |
| コンパイル使用メモリ | 169,436 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 05:24:43 |
| 合計ジャッジ時間 | 103,995 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 WA * 13 RE * 1 |
ソースコード
#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=-1e8;i<1e8;i++){
if(calc(i)==0) ans.insert(i);
}
if((int)ans.size()<3){
Int k=*ans.begin();
P=A+k,Q=k*(A+k);
//cout<<ans.size()<<endl;
cout<<P<<" "<<Q<<endl;
{
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;
//cout<<M<<":"<<calc(M)<<endl;
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=-P/2,R=INT_MAX;
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;
//cout<<M<<":"<<calc(M)<<endl;
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);
}
if(ans.size()==2) ans.insert(-C/ *ans.begin() / *++ans.begin());
}
bool flg=0;
for(Int i:ans){
if(flg) cout<<" ";
cout<<i;
flg=1;
}
cout<<endl;
return 0;
}
beet