結果

問題 No.955 ax^2+bx+c=0
ユーザー trineutron
提出日時 2020-04-17 21:14:32
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-10-03 10:43:29
合計ジャッジ時間 6,090 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 120 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

from decimal import Decimal, getcontext
getcontext().prec = 17

a, b, c = map(int, input().split())
A, B, C = map(Decimal, [a, b, c])

if a==0:
    if b==0 and c==0: print(-1);
    elif b==0 and c!=0: print(0);
    else:
        print(1);
        print(-C/B);
else:
    if b*b-4*a*c < 0: print(0);
    elif b*b-4*a*c == 0:
        print(1)
        print(-B/(2*A))
    else:
        if B < 0:
            A, B, C = -A, -B, -C
        print(2)
        x1 = (-B-(B*B-4*A*C).sqrt())/(2*A)
        x2 = (2*C)/(-B-(B*B-4*A*C).sqrt())
        print(min(x1, x2))
        print(max(x1, x2))
0