結果
| 問題 |
No.550 夏休みの思い出(1)
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2017-07-28 23:52:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 244 ms / 2,000 ms |
| コード長 | 2,046 bytes |
| コンパイル時間 | 1,527 ms |
| コンパイル使用メモリ | 168,820 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 05:34:58 |
| 合計ジャッジ時間 | 14,910 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
ソースコード
#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=-1e7;i<1e7;i++){
if(calc(i)==0) ans.insert(i);
}
if((int)ans.size()<3){
Int k=*ans.begin();
//cout<<k<<endl;
P=A+k;Q=k*(A+k)+B;
//cout<<ans.size()<<endl;
//cout<<P<<" "<<Q<<endl;
{
Int L=INT_MIN,R=-P/2;
for(Int i=-1e5;i<1e5;i++)
if(calc2(R+i)==0) ans.insert(R+i);
while(L+1<R){
Int M=(L+R)/2;
//cout<<M<<":"<<calc2(M)<<endl;
if(calc2(M)>0) L=M;
else R=M;
for(Int i=-1e5;i<1e5;i++)
if(calc2(R+i)==0) ans.insert(R+i);
}
for(Int i=-1e5;i<1e5;i++)
if(calc2(R+i)==0) ans.insert(R+i);
}
{
Int L=-P/2,R=INT_MAX;
for(Int i=-1e5;i<1e5;i++)
if(calc2(L+i)==0) ans.insert(L+i);
while(L+1<R){
Int M=(L+R)/2;
//cout<<M<<":"<<calc2(M)<<endl;
if(calc2(M)<=0) L=M;
else R=M;
for(Int i=-1e5;i<1e5;i++)
if(calc2(L+i)==0) ans.insert(L+i);
}
for(Int i=-1e5;i<1e5;i++)
if(calc2(L+i)==0) ans.insert(L+i);
}
if(ans.size()==2) ans.insert(-C/ *ans.begin() / *++ans.begin());
}
assert(ans.size()==3);
bool flg=0;
for(Int i:ans){
if(flg) cout<<" ";
cout<<i;
flg=1;
}
cout<<endl;
return 0;
}
beet