結果

問題 No.550 夏休みの思い出(1)
ユーザー milanis48663220milanis48663220
提出日時 2019-09-28 20:35:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 60,808 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 07:00:48
合計ジャッジ時間 2,786 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 4 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 3 ms
6,940 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 3 ms
6,944 KB
testcase_40 AC 3 ms
6,940 KB
testcase_41 AC 3 ms
6,940 KB
testcase_42 AC 2 ms
6,944 KB
testcase_43 AC 2 ms
6,940 KB
testcase_44 AC 2 ms
6,944 KB
testcase_45 AC 2 ms
6,940 KB
testcase_46 AC 2 ms
6,944 KB
testcase_47 AC 2 ms
6,940 KB
testcase_48 AC 3 ms
6,940 KB
testcase_49 AC 3 ms
6,944 KB
testcase_50 AC 3 ms
6,940 KB
testcase_51 AC 3 ms
6,944 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:20: warning: ‘ans[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |         b = A+ans[0];
      |               ~~~~~^

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

const int N = 1e6;

ll A, B, C;

ll calc(ll x){
    return x*x*x+A*x*x+B*x+C;
}

int main(){
    cin >> A >> B >> C;
    int ans[3];
    for(int i = -N; i <= N; i++){
        if(calc(i) == 0){
            ans[0] = i;
            break;
        }
    }
    ll b, c;
    if(ans[0] == 0){
        b = A;
        c = C;
    }else{
        b = A+ans[0];
        c = -C/ans[0];
    }
    ll sq = sqrt(b*b-4*c);
    if((sq+1)*(sq+1) == b*b-4*c) sq = sq+1;
    ans[1] = (-b-sq)/2;
    ans[2] = (-b+sq)/2;
    cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
}
0