結果

問題 No.955 ax^2+bx+c=0
ユーザー yuppe19 😺
提出日時 2019-12-18 15:23:55
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-07-07 00:48:50
合計ジャッジ時間 5,439 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 102 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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)
for token in res:
    print token
0