結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー koyopro
提出日時 2020-01-25 15:42:52
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 121 ms / 2,000 ms
+ 110µs
コード長 697 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 111 ms
コンパイル使用メモリ 62,892 KB
実行使用メモリ 80,560 KB
最終ジャッジ日時 2026-10-19 14:57:55
合計ジャッジ時間 19,692 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 123
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from decimal import *

a,b,c = [Decimal(int(x)) for x in raw_input().split()]

def solve():
    if (a==0 and b==0):
        print(-1 if (c==0) else 0)
        return

    if (a==0):
        print(1)
        ans = -c/b
        print("{:.16f}".format(ans))
        return

    border = Decimal(b*b - 4 * a * c)
    if (border < 0):
        print(0)
        return

    if (border == 0):
        print(1)
        ans = -b / Decimal(2) / a
        print("{:.16f}".format(ans))
        return

    q = border.sqrt()
    ans0 = (-b + q) / Decimal(2) / a
    ans1 = (-b - q) / Decimal(2) / a
    print(2)
    print("{:.16f}".format(min(ans0, ans1)))
    print("{:.16f}".format(max(ans0, ans1)))

solve()
0