結果

問題 No.955 ax^2+bx+c=0
ユーザー 👑 Kazun
提出日時 2021-01-01 18:27:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 80,384 KB
最終ジャッジ日時 2024-10-11 12:09:39
合計ジャッジ時間 19,640 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 97 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
import decimal

decimal.getcontext().prec=20

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

if a<0:
    a=-a;b=-b;c=-c

D=b*b-4*a*c

if a==0:
    if b==0:
        if c==0:
            print(-1)
        else:
            print(0)
    else:
        print(1)
        b=decimal.Decimal(b)
        c=decimal.Decimal(c)
        print(-c/b)
else:
    a=decimal.Decimal(a)
    b=decimal.Decimal(b)
    c=decimal.Decimal(c)
    if D<0:
        print(0)
    elif D==0:
        print(1)
        print(-b/(2*a))
    else:
        print(2)
        R=decimal.Decimal(sqrt(D))
        print((-b-R)/(2*a))
        print((-b+R)/(2*a))
0