結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー yuppe19 😺
提出日時 2019-12-18 16:14:00
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 123 ms / 2,000 ms
+ 882µs
コード長 500 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 75 ms
コンパイル使用メモリ 62,336 KB
実行使用メモリ 80,512 KB
最終ジャッジ日時 2026-10-19 14:48:40
合計ジャッジ時間 20,171 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 123
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
from decimal import *

def f(a, b, c):
    if a == 0:
        if b == 0:
            return [-1] if c == 0 else [0]
        return [1, -c/b]
    else:
        D = b*b - 4*a*c
        if D < 0:
            return [0]
        if D == 0:
            return [1, -b/(2*a)]
        return [2, (-b-D.sqrt())/(2*a), (-b+D.sqrt())/(2*a)]


a, b, c = map(Decimal, raw_input().split())
res = f(a, b, c)
print res[0]
for token in sorted(res[1:]):
    print token
0