結果

問題 No.550 夏休みの思い出(1)
ユーザー RisenRisen
提出日時 2017-07-29 03:38:18
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,441 bytes
コンパイル時間 1,028 ms
コンパイル使用メモリ 113,052 KB
実行使用メモリ 28,820 KB
最終ジャッジ日時 2024-04-19 04:06:44
合計ジャッジ時間 5,140 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
26,540 KB
testcase_01 AC 45 ms
28,436 KB
testcase_02 AC 46 ms
26,668 KB
testcase_03 AC 47 ms
28,700 KB
testcase_04 AC 47 ms
26,408 KB
testcase_05 AC 47 ms
26,408 KB
testcase_06 AC 44 ms
26,404 KB
testcase_07 AC 45 ms
28,568 KB
testcase_08 AC 45 ms
26,544 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 46 ms
26,792 KB
testcase_12 AC 45 ms
28,556 KB
testcase_13 AC 45 ms
26,536 KB
testcase_14 AC 45 ms
28,328 KB
testcase_15 AC 46 ms
26,788 KB
testcase_16 AC 45 ms
28,700 KB
testcase_17 AC 46 ms
28,444 KB
testcase_18 AC 46 ms
28,692 KB
testcase_19 AC 46 ms
26,400 KB
testcase_20 AC 47 ms
28,572 KB
testcase_21 AC 45 ms
28,696 KB
testcase_22 AC 43 ms
26,284 KB
testcase_23 AC 44 ms
28,316 KB
testcase_24 AC 45 ms
24,760 KB
testcase_25 AC 44 ms
26,664 KB
testcase_26 AC 45 ms
26,660 KB
testcase_27 AC 45 ms
28,556 KB
testcase_28 AC 47 ms
28,576 KB
testcase_29 AC 47 ms
28,576 KB
testcase_30 AC 46 ms
28,316 KB
testcase_31 AC 47 ms
24,376 KB
testcase_32 AC 47 ms
26,644 KB
testcase_33 AC 48 ms
28,820 KB
testcase_34 AC 47 ms
28,560 KB
testcase_35 AC 47 ms
26,272 KB
testcase_36 AC 47 ms
26,260 KB
testcase_37 AC 44 ms
26,280 KB
testcase_38 AC 44 ms
26,668 KB
testcase_39 AC 45 ms
28,188 KB
testcase_40 AC 45 ms
26,652 KB
testcase_41 AC 45 ms
28,320 KB
testcase_42 AC 44 ms
26,412 KB
testcase_43 AC 45 ms
26,292 KB
testcase_44 AC 46 ms
26,412 KB
testcase_45 AC 43 ms
26,268 KB
testcase_46 AC 44 ms
26,540 KB
testcase_47 AC 44 ms
28,692 KB
testcase_48 AC 44 ms
26,656 KB
testcase_49 AC 42 ms
26,416 KB
testcase_50 AC 43 ms
28,320 KB
testcase_51 AC 45 ms
24,500 KB
testcase_52 AC 45 ms
26,504 KB
testcase_53 AC 44 ms
26,796 KB
testcase_54 AC 44 ms
28,320 KB
testcase_55 AC 45 ms
26,672 KB
testcase_56 AC 46 ms
26,648 KB
testcase_57 AC 45 ms
26,796 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Numerics;
using System.Linq;

class Solution
{
    // ビエタの解
    static double[] Solve(BigInteger a, BigInteger b, BigInteger c)
    {
        var p = (double)(3 * b - a * a) / 9;
        var q = (double)(2 * a * a * a - 9 * a * b + 27 * c) / 54;
        var lamda = 2 * Math.Sqrt(-p);
        var theta = Math.Acos(-q / Math.Sqrt(-p * p * p)) / 3;
        var gamma = (double)a / 3;
        var x = new double[3];
        x[0] = lamda * Math.Cos(theta + 2 * Math.PI / 3) - gamma;
        x[1] = lamda * Math.Cos(theta - 2 * Math.PI / 3) - gamma;
        x[2] = lamda * Math.Cos(theta) - gamma;
        return x;
    }

    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(BigInteger.Parse).ToArray();
        var a = vals[0];
        var b = vals[1];
        var c = vals[2];

        var xs = Solve(a, b, c).Distinct().Select(d => new BigInteger(Math.Round(d))).ToList();

        // 計算誤差対策のため,チェック
        foreach (var x in xs.ToList())
        {
            if (x * x * x + a * x * x + b * x + c != 0)
            {
                xs.Remove(x);
            }
        }

        // 1ミスのみ救済 (手抜き)
        if (xs.Count == 2)
        {
            // C == −αβγ より
            var x = -c / xs[0] / xs[1];
            xs.Add(x);
            xs.Sort();
        }

        Console.WriteLine(string.Join(" ", xs));
    }
}
0