結果

問題 No.550 夏休みの思い出(1)
ユーザー sekiya9311sekiya9311
提出日時 2017-07-29 11:21:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,430 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 167,456 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 04:56:13
合計ジャッジ時間 4,247 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

long long a, b, c;

inline long long calc(long long x) {
    return x * x * x + a * x * x + b * x + c;
}

// a = -(alpha + beta + gamma) = -alpha - (beta + gamma)
// b = alpha*beta + beta*gamma + gamma*alpha
// c = -alpha*beta*gamma
/*
 -(beta + gamma) = a + alpha      beta + gamma = -a - alpha   gamma = -a - alpha - beta
 b = alpha*beta + beta*(-a - alpha - beta) + (-a - alpha - beta)*alpha
 b = - beta*a - beta*alpha - beta^2 - a*alpha - alpha^2
   = -beta^2 - (a + alpha)*beta - (a*alpha + alpha^2)
beta^2 + (a + alpha)*beta + (a*alpha + alpha^2 + b) = 0
*/
int main() {
    cin >> a >> b >> c;
    long long ans[3];
    for (long long int al = -1e7; al <= 1e7; al++) {
        if (calc(al) == 0) {
            ans[0] = al;
            const long long A = 1;
            const long long B = a + al;
            const long long C = a*al + al*al + b;
            ans[1] = (-B + sqrtl(B * B - 4 * A * C)) / (2 * A);
            ans[2] = (-B - sqrtl(B * B - 4 * A * C)) / (2 * A);
            sort(ans, ans + 3);
            if (ans[1] == ans[0]) {
                ans[1] = -c / (ans[0] * ans[2]);
            } else if (ans[2] == ans[1]) {
                ans[2] = -c / (ans[0] * ans[1]);
            }
            sort(ans, ans + 3);
            break;
        }
    }
    for (int i = 0; i < 3; i++) {
        cout << ans[i] << (i + 1 == 3 ? "\n" : " ");
    }
    return 0;
}
0