結果

問題 No.550 夏休みの思い出(1)
ユーザー btkbtk
提出日時 2017-04-06 00:07:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,520 bytes
コンパイル時間 1,691 ms
コンパイル使用メモリ 171,476 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 13:07:11
合計ジャッジ時間 3,424 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
6,812 KB
testcase_01 AC 31 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 16 ms
6,940 KB
testcase_10 AC 15 ms
6,944 KB
testcase_11 AC 15 ms
6,940 KB
testcase_12 AC 15 ms
6,940 KB
testcase_13 AC 16 ms
6,944 KB
testcase_14 AC 15 ms
6,944 KB
testcase_15 AC 19 ms
6,940 KB
testcase_16 AC 16 ms
6,944 KB
testcase_17 AC 16 ms
6,940 KB
testcase_18 AC 16 ms
6,940 KB
testcase_19 AC 16 ms
6,940 KB
testcase_20 AC 20 ms
6,944 KB
testcase_21 AC 19 ms
6,944 KB
testcase_22 AC 6 ms
6,944 KB
testcase_23 AC 12 ms
6,940 KB
testcase_24 AC 10 ms
6,940 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 7 ms
6,940 KB
testcase_30 AC 4 ms
6,940 KB
testcase_31 AC 16 ms
6,944 KB
testcase_32 AC 16 ms
6,940 KB
testcase_33 AC 15 ms
6,940 KB
testcase_34 AC 16 ms
6,940 KB
testcase_35 AC 15 ms
6,940 KB
testcase_36 AC 16 ms
6,944 KB
testcase_37 AC 16 ms
6,940 KB
testcase_38 AC 16 ms
6,940 KB
testcase_39 AC 15 ms
6,944 KB
testcase_40 AC 14 ms
6,940 KB
testcase_41 AC 15 ms
6,940 KB
testcase_42 AC 10 ms
6,940 KB
testcase_43 AC 2 ms
6,944 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 AC 2 ms
6,944 KB
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 7 ms
6,940 KB
testcase_48 AC 16 ms
6,944 KB
testcase_49 AC 19 ms
6,944 KB
testcase_50 AC 16 ms
6,940 KB
testcase_51 AC 15 ms
6,944 KB
testcase_52 AC 15 ms
6,944 KB
testcase_53 AC 17 ms
6,940 KB
testcase_54 AC 16 ms
6,940 KB
testcase_55 AC 15 ms
6,940 KB
testcase_56 AC 15 ms
6,940 KB
testcase_57 AC 16 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'LL getone(INT, INT, INT)':
main.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^

ソースコード

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;
INT one=1;
LL getone(INT a,INT b,INT c){
    FOR(i,-1000001,1000001)if(i==0||c%i==0){
        INT sum=one*i*i*i+a*i*i+b*i+c;
        if(sum==0)return i;        
    }
    
}

INT square_root(INT XX){
    INT ok=0,ng=1e18+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;
    INT 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
    {
        INT sq=square_root(one*A*A-4*B);
        res.pb((LL)(-A+sq)/2);
        res.pb((LL)(-A-sq)/2);
    }    
    sort(ALL(res));
    cout<<res[0]<<" "<<res[1]<<" "<<res[2]<<endl;
    return 0;
}
0