結果

問題 No.1179 Quadratic Equation
ユーザー lam6er
提出日時 2025-03-20 21:18:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 82,052 KB
実行使用メモリ 53,668 KB
最終ジャッジ日時 2025-03-20 21:19:44
合計ジャッジ時間 1,291 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

a, b, c = map(int, input().split())

D = b ** 2 - 4 * a * c

if D < 0:
    print("imaginary")
else:
    if D == 0:
        x = (-b) / (2 * a)
        print("{0:.15f}".format(x))
    else:
        sqrt_d = math.sqrt(D)
        x1 = (-b - sqrt_d) / (2 * a)
        x2 = (-b + sqrt_d) / (2 * a)
        sorted_roots = sorted([x1, x2])
        print("{0:.15f} {1:.15f}".format(sorted_roots[0], sorted_roots[1]))
0