結果

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

ソースコード

diff #

L = 10 ** 15

def mysqrt(x):
    ok, ng = 1, L ** 4
    while ok + 1 < ng:
        m = (ok + ng) // 2
        if m * m <= x:
            ok = m
        else:
            ng = m
    return ok

a, b, c = map(int, input().split())
if a == 0:
    if b == 0:
        print(-1 if c == 0 else 0)
    else:
        print(1, -c / b, sep='\n')
else:
    if a < 0:
        a, b, c = -a, -b, -c
    p = b * b - a * c * 4
    if p == 0:
        print(1, -b / a / 2, sep='\n')
    elif p > 0:
        d = mysqrt(p * (L ** 2))
        print(2, -(d + b * L) / a / 2 / L, (d - b * L) / a / 2 / L, sep='\n')
    else:
        print(0)
0