結果

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

ソースコード

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(-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(-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(-b/a-ans)
    print(ans)
0