結果

問題 No.955 ax^2+bx+c=0
ユーザー ayaoniayaoni
提出日時 2020-12-09 17:01:04
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,194 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 80,640 KB
最終ジャッジ日時 2024-09-19 01:16:30
合計ジャッジ時間 5,960 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 TLE * 1 -- * 90
権限があれば一括ダウンロードができます

ソースコード

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()

if a == 0:
    if b != 0:
        print(1)
        print(-c/b)
    else:
        if c == 0:
            print(-1)
        else:
            print(0)
elif b**2 > 4*a*c:
    if a < 0:
        a,b,c = -a,-b,-c
    pos = -10**10
    neg = -b/(2*a)
    while 10**12*(neg-pos) >= 1:
        mid = (pos+neg)/2
        if a*mid**2+b*mid+c > 0:
            pos = mid
        else:
            neg = mid
    sol0 = pos
    pos = 10**10
    neg = -b/(2*a)
    while 10**12*(pos-neg) >= 1:
        mid = (pos+neg)/2
        if a*mid**2+b*mid+c > 0:
            pos = mid
        else:
            neg = mid
    sol1 = pos
    print(2)
    print(sol0)
    print(sol1)

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