結果

問題 No.955 ax^2+bx+c=0
ユーザー ayaoni
提出日時 2020-12-09 17:25:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-19 01:18:52
合計ジャッジ時間 6,661 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 97 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


a,b,c = MI()

D = b**2-4*a*c

if a == 0:
    if b != 0:
        print(1)
        print(-c/b)
    else:
        if c == 0:
            print(-1)
        else:
            print(0)
elif D > 0:
    if a < 0:
        a,b,c = -a,-b,-c

    sol0 = (-b-D**.5)/(2*a)
    sol1 = -b/a-sol0

    print(2)
    print(sol0)
    print(sol1)

elif D == 0:
    print(1)
    print(-b/(2*a))
else:
    print(0)
0