結果
| 問題 | No.550 夏休みの思い出(1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-29 03:18:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,788 bytes |
| 記録 | |
| コンパイル時間 | 1,955 ms |
| コンパイル使用メモリ | 171,568 KB |
| 実行使用メモリ | 16,832 KB |
| 最終ジャッジ日時 | 2024-10-10 20:34:56 |
| 合計ジャッジ時間 | 8,454 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 54 |
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl
using namespace std;
typedef pair<int,int>P;
const int MAX_N = 100005;
double na,nb,nc;
map<int,int> mp;
int eq(double kai)
{
double res = kai*(kai*(kai+na)+nb)+nc;
if(abs(res) < EPS){
return 0;
}else if(res > 0){
return 1;
}else{
return 2;
}
}
int eq2(double kai)
{
double res = kai*(kai*(kai+na)+nb)+nc;
if(abs(res) < EPS){
return 0;
}else if(res < 0){
return 1;
}else{
return 2;
}
}
ll aida(ll a,ll b)
{
if(a >= 0){
return (a+b)/2;
}else{
b += (-a);
ll bf = a;
a = 0;
return (a+b)/2+bf;
}
}
int main()
{
ll a,b,c;
cin >> a >> b >> c;
na = a,nb = b,nc = c;
double x = (-na-sqrt(na*na-3*nb))/3.0;
double y = (-na+sqrt(na*na-3*nb))/3.0;
ll h = (ll)x;
ll l = -(ll)pow(10,9);
vector<int> ans;
if(eq(h) == 0){
ans.pb(h);
mp[h]++;
}else{
while(1){
ll mid = aida(l,h);
int res = eq(mid);
if(res == 0){
ans.pb(mid);
mp[mid]++;
break;
}else if(res == 1){
h = mid;
}else{
l = mid;
}
}
}
h = (ll)y;
l = (ll)x;
if(eq2(h) == 0 && mp[h] == 0){
ans.pb(h);
mp[h]++;
}else if(eq2(l) == 0 && mp[l] == 0){
ans.pb(l);
mp[l]++;
}else{
while(1){
ll mid = aida(l,h);
int res = eq2(mid);
if(res == 0){
ans.pb(mid);
mp[mid]++;
break;
}else if(res == 1){
h = mid;
}else{
l = mid;
}
}
}
h = (ll)pow(10,9);
l = (ll)y;
if(eq(l) == 0 && mp[l] == 0){
ans.pb(l);
}else{
while(1){
ll mid = aida(l,h);
int res = eq(mid);
if(res == 0){
ans.pb(mid);
break;
}else if(res == 1){
h = mid;
}else{
l = mid;
}
}
}
sort(all(ans));
cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
return 0;
}