結果
| 問題 |
No.550 夏休みの思い出(1)
|
| ユーザー |
gigime
|
| 提出日時 | 2017-07-28 22:57:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,457 bytes |
| コンパイル時間 | 1,712 ms |
| コンパイル使用メモリ | 174,636 KB |
| 実行使用メモリ | 191,604 KB |
| 最終ジャッジ日時 | 2024-10-10 04:29:08 |
| 合計ジャッジ時間 | 8,447 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 54 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;
double A,B,C;
const double MAX_A = 1e18;
const double EPS = 1e-1;
double f(double x)
{
return x * x * x + A * x * x + B * x + C;
}
double solve(double l,double r)
{
if(f(l) >= EPS) swap(l,r);
FOR(i,0,200){
double mid = (l + r) / 2.0;
if(f(mid) >= EPS){
r = mid;
}
else{
l = mid;
}
}
return (l + r) / 2.0;
}
int main()
{
scanf("%lf%lf%lf",&A,&B,&C);
vector<ll> ans(1,solve(-MAX_A,MAX_A));
while(ans.size() < 3){
double x = solve(-MAX_A,ans.front() - 1);
if(abs(f(x)) < EPS){
ans.push_back(ll(x * 2) - ll(x));
sort(ans.begin(),ans.end());
ans.erase(unique(ans.begin(),ans.end()),ans.end());
}
x = solve(ans.back() + 1,MAX_A);
if(abs(f(x)) < EPS){
ans.push_back(ll(x * 2) - ll(x));
sort(ans.begin(),ans.end());
ans.erase(unique(ans.begin(),ans.end()),ans.end());
}
FOR(i,1,ans.size()){
x = solve(ans [i - 1] + 1,ans [i] - 1);
if(abs(f(x)) < EPS){
ans.push_back(ll(x * 2) - ll(x));
sort(ans.begin(),ans.end());
ans.erase(unique(ans.begin(),ans.end()),ans.end());
}
}
}
FOR(i,0,ans.size()){
printf("%lld%s",ans [i],i + 1 == ans.size() ? "\n" : " ");
}
return 0;
}
gigime