結果

問題 No.955 ax^2+bx+c=0
ユーザー lam6er
提出日時 2025-03-20 21:20:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 54,128 KB
最終ジャッジ日時 2025-03-20 21:21:12
合計ジャッジ時間 8,673 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 97 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

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

if a == 0:
    if b == 0:
        if c == 0:
            print(-1)
        else:
            print(0)
    else:
        x = (-c) / b
        print(1)
        print("{0:.15g}".format(x))
else:
    D = b * b - 4 * a * c
    if D < 0:
        print(0)
    elif D == 0:
        x = (-b) / (2 * a)
        print(1)
        print("{0:.15g}".format(x))
    else:
        sqrtD = math.sqrt(D)
        x1 = (-b - sqrtD) / (2 * a)
        x2 = (-b + sqrtD) / (2 * a)
        if x1 > x2:
            x1, x2 = x2, x1
        print(2)
        print("{0:.15g}".format(x1))
        print("{0:.15g}".format(x2))
0