結果

問題 No.550 夏休みの思い出(1)
ユーザー btkbtk
提出日時 2017-04-08 15:56:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,862 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 171,348 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-24 23:30:48
合計ジャッジ時間 9,590 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef __int128 INT;
const INT inf=1e9;
const INT INF=1e18;

INT getone(INT a,INT b,INT c){
    if(c==0)return 0;
    auto f=[&](INT x){return x*x*x+a*x*x+b*x+c;};
    INT ok=-INF,ng=INF;
    if(f(ok)>0)swap(ok,ng);
    while(max(ok-ng,ng-ok)>1){
        const INT mid=(ok+ng)/2;
        if(f(mid)<0)ng=mid;
        else ok=mid;
    }
    return ok;
}
LL square_root(INT XX){
   INT ok=0,ng=2*inf+1;
    while(ng-ok>1){
        INT mid=(ok+ng)/2;
        if(mid*mid<=XX)ok=mid;
        else ng=mid;
    }
    return ok;
}

int main(){
    LL a,b,c;
    //xxx+Axx+Bx+C==0
    cin>>a>>b>>c;    
    LL A(a),B(b),C(c);
    vector<LL> res;
    res.pb(getone(A,B,C));
    //(x-res[0])(xx+Ax+B)==0
    A+=res[0];
    B+=A*res[0];
    //x=(-A+-sqrt(AA-4B))/2
    {
        LL sq=square_root(A*A-4*B);
        res.pb((-A+sq)/2);
        res.pb((-A-sq)/2);
    }    
    sort(ALL(res));
    cout<<res[0]<<" "<<res[1]<<" "<<res[2]<<endl;
    assert(-INF<a&&a<INF);
    assert(-INF<b&&b<INF);
    assert(-INF<c&&c<INF);

    REP(i,3){
        assert(-inf<res[i]&&res[i]<inf);
    }
    REP(i,2){
        assert(res[i]!=res[i+1]);
    }
    return 0;
}
0