結果

問題 No.955 ax^2+bx+c=0
ユーザー roarisroaris
提出日時 2019-12-18 00:22:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,171 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 86,800 KB
実行使用メモリ 80,008 KB
最終ジャッジ日時 2023-09-21 05:23:34
合計ジャッジ時間 7,092 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,488 KB
testcase_01 AC 75 ms
70,964 KB
testcase_02 AC 72 ms
71,192 KB
testcase_03 AC 71 ms
71,380 KB
testcase_04 AC 72 ms
71,304 KB
testcase_05 AC 71 ms
71,244 KB
testcase_06 AC 72 ms
71,036 KB
testcase_07 AC 73 ms
71,168 KB
testcase_08 AC 73 ms
71,196 KB
testcase_09 AC 72 ms
71,136 KB
testcase_10 AC 72 ms
71,300 KB
testcase_11 AC 72 ms
71,132 KB
testcase_12 AC 72 ms
71,188 KB
testcase_13 AC 72 ms
71,080 KB
testcase_14 AC 73 ms
71,232 KB
testcase_15 AC 72 ms
71,060 KB
testcase_16 AC 72 ms
71,184 KB
testcase_17 AC 73 ms
71,064 KB
testcase_18 AC 72 ms
71,048 KB
testcase_19 AC 71 ms
71,260 KB
testcase_20 AC 74 ms
70,968 KB
testcase_21 AC 74 ms
71,140 KB
testcase_22 AC 74 ms
71,448 KB
testcase_23 AC 72 ms
71,060 KB
testcase_24 AC 72 ms
71,116 KB
testcase_25 AC 73 ms
71,328 KB
testcase_26 AC 72 ms
70,960 KB
testcase_27 AC 73 ms
71,120 KB
testcase_28 AC 74 ms
71,376 KB
testcase_29 AC 73 ms
71,140 KB
testcase_30 AC 73 ms
71,292 KB
testcase_31 AC 73 ms
71,128 KB
testcase_32 AC 73 ms
71,112 KB
testcase_33 AC 71 ms
71,316 KB
testcase_34 TLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
testcase_94 -- -
testcase_95 -- -
testcase_96 -- -
testcase_97 -- -
testcase_98 -- -
testcase_99 -- -
testcase_100 -- -
testcase_101 -- -
testcase_102 -- -
testcase_103 -- -
testcase_104 -- -
testcase_105 -- -
testcase_106 -- -
testcase_107 -- -
testcase_108 -- -
testcase_109 -- -
testcase_110 -- -
testcase_111 -- -
testcase_112 -- -
testcase_113 -- -
testcase_114 -- -
testcase_115 -- -
testcase_116 -- -
testcase_117 -- -
testcase_118 -- -
testcase_119 -- -
testcase_120 -- -
testcase_121 -- -
testcase_122 -- -
testcase_123 -- -
testcase_124 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    return a*x**2+b*x+c
    
def binary_search1(l, r):
    left, right = l, r
    
    while right-left>=1e-15:
        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-15:
        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