結果

問題 No.550 夏休みの思い出(1)
ユーザー koprickykopricky
提出日時 2017-07-29 03:31:26
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,907 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 172,376 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-04-19 04:02:45
合計ジャッジ時間 5,136 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,320 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define double long double
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-15
#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-0.5);
    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-0.5);
    l = (ll)(x+0.5);
    if(eq2(l) == 0 && mp[l] == 0){
        ans.pb(l);
        mp[l]++;
    }else if(eq2(h) == 0 && mp[h] == 0){
        ans.pb(h);
        mp[h]++;
    }else{
        while(1){
            ll mid = aida(l,h);
            int res = eq2(mid);
            if(res == 0){
                ans.pb(mid);
                break;
            }else if(res == 1){
                h = mid;
            }else{
                l = mid;
            }
        }
    }
    h = (ll)pow(10,9);
    l = (ll)(y+0.5);
    ll hoge = (ll)(y-0.5);
    if(eq(hoge) == 0 && mp[hoge] == 0){
        ans.pb(hoge);
    }else 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;
}
0