結果

問題 No.550 夏休みの思い出(1)
ユーザー RisenRisen
提出日時 2017-07-29 03:33:27
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,446 bytes
コンパイル時間 2,539 ms
コンパイル使用メモリ 108,416 KB
実行使用メモリ 20,864 KB
最終ジャッジ日時 2024-04-19 04:06:06
合計ジャッジ時間 6,989 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
20,736 KB
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 AC 51 ms
20,736 KB
testcase_10 AC 50 ms
20,480 KB
testcase_11 AC 48 ms
20,608 KB
testcase_12 AC 49 ms
20,480 KB
testcase_13 AC 48 ms
20,352 KB
testcase_14 AC 49 ms
20,736 KB
testcase_15 AC 49 ms
20,608 KB
testcase_16 AC 49 ms
20,736 KB
testcase_17 AC 49 ms
20,736 KB
testcase_18 AC 50 ms
20,608 KB
testcase_19 AC 47 ms
20,480 KB
testcase_20 AC 49 ms
20,480 KB
testcase_21 AC 50 ms
20,352 KB
testcase_22 AC 50 ms
20,736 KB
testcase_23 AC 50 ms
20,480 KB
testcase_24 AC 48 ms
20,480 KB
testcase_25 AC 48 ms
20,480 KB
testcase_26 AC 49 ms
20,352 KB
testcase_27 AC 51 ms
20,352 KB
testcase_28 AC 49 ms
20,608 KB
testcase_29 AC 49 ms
20,608 KB
testcase_30 AC 49 ms
20,736 KB
testcase_31 AC 48 ms
20,224 KB
testcase_32 AC 48 ms
20,224 KB
testcase_33 AC 48 ms
20,736 KB
testcase_34 AC 48 ms
20,608 KB
testcase_35 AC 49 ms
20,480 KB
testcase_36 AC 49 ms
20,608 KB
testcase_37 AC 47 ms
20,480 KB
testcase_38 AC 48 ms
20,864 KB
testcase_39 AC 48 ms
20,608 KB
testcase_40 AC 48 ms
20,736 KB
testcase_41 AC 49 ms
20,480 KB
testcase_42 AC 47 ms
20,608 KB
testcase_43 AC 48 ms
20,736 KB
testcase_44 AC 48 ms
20,608 KB
testcase_45 AC 49 ms
20,736 KB
testcase_46 AC 51 ms
20,352 KB
testcase_47 AC 49 ms
20,608 KB
testcase_48 AC 48 ms
20,608 KB
testcase_49 RE -
testcase_50 RE -
testcase_51 AC 47 ms
20,352 KB
testcase_52 AC 49 ms
20,224 KB
testcase_53 AC 47 ms
20,480 KB
testcase_54 AC 48 ms
20,480 KB
testcase_55 AC 48 ms
20,736 KB
testcase_56 AC 47 ms
20,480 KB
testcase_57 AC 49 ms
20,608 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 = ((3 * b - a * a) / 9);
        var q = ((2 * a * a * a - 9 * a * b + 27 * c) / 54);
        var lamda = 2 * Math.Sqrt((double)-p);
        var theta = Math.Acos((double)-q / Math.Sqrt((double)(-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)
        {
            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