結果

問題 No.955 ax^2+bx+c=0
ユーザー chocorusk
提出日時 2019-12-18 03:52:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-09-18 22:07:20
合計ジャッジ時間 5,993 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 122
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from decimal import *
a, b, c=map(int, input().split())
if a==0:
    if b==0:
        if c==0:
            print(-1)
        else:
            print(0)
    else:
        print(1)
        print('{:.12g}'.format(-c/b))
    sys.exit()
if a<0:
    a=-a
    b=-b
    c=-c
d=b*b-4*a*c
if d<0:
    print(0)
elif d==0:
    print(1)
    print('{:.12g}'.format(-b/(2*a)))
else:
    print(2)
    a1=Decimal(a)
    b1=Decimal(b)
    c1=Decimal(c)
    d1=Decimal(d)
    ans1=(-b1-Decimal.sqrt(d1))/(2*a1)
    ans2=(-b1+Decimal.sqrt(d1))/(2*a1)
    print(ans1)
    print(ans2)
0