結果

問題 No.955 ax^2+bx+c=0
ユーザー roarisroaris
提出日時 2019-12-18 00:36:48
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,206 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 65,308 KB
最終ジャッジ日時 2024-07-06 23:58:04
合計ジャッジ時間 5,165 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 TLE * 1 -- * 90
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
def f(x):
    return a*x**2+b*x+c
    
def binary_search1(l, r):
    left, right = l, r
    
    while right-left>=1e-12:
        mid = (left+right)/2
        
        if f(mid)>=0:
            right = mid
        else:
            left = mid
    
    return left

def binary_search2(l, r):
    left, right = l, r
    
    while right-left>=1e-12:
        mid = (left+right)/2
        
        if f(mid)<=0:
            right = mid
        else:
            left = mid
    
    return left
    
a, b, c = map(int, input().split())

if a==0:
    if b==0:
        if c==0:
            print(-1)
        else:
            print(0)
    else:
        print(1)
        print("{:.15f}".format(-c/b))
else:
    if b**2-4*a*c>0:
        print(2)
        if a>0:
            ans1 = binary_search1(-b/2/a, 10**100)
            ans2 = binary_search2(-10**100, -b/2/a)
        else:
            ans1 = binary_search2(-b/2/a, 10**100)
            ans2 = binary_search1(-10**100, -b/2/a)
            
        print("{:.15f}".format(ans2))
        print("{:.15f}".format(ans1))
    elif b**2-4*a*c==0:
        print(1)
        print("{:.15f}".format(-b/(2*a)))
    else:
        print(0)
0