結果

問題 No.955 ax^2+bx+c=0
ユーザー chocorusk
提出日時 2019-12-18 03:40:55
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-07 00:24:27
合計ジャッジ時間 5,551 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 107 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
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)
    n=10**12
    b*=n
    c*=n*n
    l=int(-b/a)
    r=2*(10**21)
    while r-l>1:
        m=(l+r)//2
        if a*m*m+b*m+c<=0:
            l=m
        else:
            r=m
    ans=l/n
    b//=n
    print('{:.12g}'.format(-b/a-ans))
    print('{:.12g}'.format(ans))
0