結果

問題 No.550 夏休みの思い出(1)
ユーザー sue_charosue_charo
提出日時 2017-07-28 23:15:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,941 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-18 11:36:30
合計ジャッジ時間 2,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

# coding: utf-8
import cmath
from cmath import log, sqrt


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    A, B, C = ILI()
    return A, B, C


def cbrt(x):
    if x.imag != 0:
        return cmath.exp(log(x) / 3)
    else:
        if x < 0:
            d = (-x) ** (1 / 3)
            return -d
        elif x >= 0:
            return x ** (1 / 3)


def cubic(a, b, c, d):
    D = (18 * a * b * c * d) - (4 * (b ** 3) * d) + ((b ** 2) * (c ** 2)) - \
    (4 * a * (c ** 3)) - (27 * (a ** 2) * d ** 2)
    D0 = (b ** 2) - (3 * a * c)
    i = 1j
    if D == 0 and D0 == 0:
        return -(b / (3 * a))
    elif D == 0 and D0 != 0:
        return [((b * c) - (9 * a * d)) / (-2 * D0), ((b ** 3) - (4 * a * b * c)
        + (9 * (a ** 2) * d)) / (-a * D0)]
    else:
        D1 = (2 * (b ** 3)) - (9 * a * b * c) + (27 * (a ** 2) * d)
        if D != 0 and D0 == 0 and D1 < 0:
            C = cbrt((D1 - sqrt((D1 ** 2) - (4 * (D0 ** 3)))) / 2)
        else:
            C = cbrt((D1 + sqrt((D1 ** 2) - (4 * (D0 ** 3)))) / 2)
            u_2 = (-1 + (i * sqrt(3))) / 2
            u_3 = (-1 - (i * sqrt(3))) / 2
            x_1 = (-(b + C + (D0 / C))) / (3 * a)
            x_2 = (-(b + (u_2 * C) + (D0 / (u_2 * C)))) / (3 * a)
            x_3 = (-(b + (u_3 * C) + (D0 / (u_3 * C)))) / (3 * a)
            if D > 0:
                return [x_1, x_2, x_3]
            else:
                return x_1


def solve(A, B, C):
    comp_ans = cubic(1, A, B, C)
    l_ans = []
    for c in comp_ans:
        l_ans.append(int(c.real))
    if len(l_ans) == 3:
        ans = " ".join(map(str, sorted(l_ans)))
    else:
        ans = "{} {} {}".format(l_ans[0], l_ans[0], l_ans[0])

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
0