結果

問題 No.955 ax^2+bx+c=0
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-02-27 18:39:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 80,836 KB
最終ジャッジ日時 2023-10-13 03:31:34
合計ジャッジ時間 29,327 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 166 ms
80,648 KB
testcase_01 AC 170 ms
80,244 KB
testcase_02 WA -
testcase_03 AC 169 ms
80,108 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 169 ms
80,240 KB
testcase_15 AC 165 ms
80,240 KB
testcase_16 AC 166 ms
80,244 KB
testcase_17 AC 166 ms
80,232 KB
testcase_18 AC 165 ms
80,060 KB
testcase_19 AC 163 ms
80,240 KB
testcase_20 AC 166 ms
80,204 KB
testcase_21 AC 167 ms
80,100 KB
testcase_22 AC 172 ms
80,088 KB
testcase_23 AC 169 ms
80,236 KB
testcase_24 AC 163 ms
80,180 KB
testcase_25 AC 162 ms
80,176 KB
testcase_26 AC 169 ms
80,240 KB
testcase_27 AC 169 ms
80,236 KB
testcase_28 AC 167 ms
80,320 KB
testcase_29 AC 164 ms
80,228 KB
testcase_30 AC 166 ms
80,348 KB
testcase_31 AC 163 ms
79,820 KB
testcase_32 AC 165 ms
80,044 KB
testcase_33 AC 165 ms
80,184 KB
testcase_34 AC 165 ms
80,588 KB
testcase_35 AC 165 ms
80,708 KB
testcase_36 AC 167 ms
80,584 KB
testcase_37 AC 171 ms
80,836 KB
testcase_38 AC 167 ms
80,708 KB
testcase_39 AC 164 ms
80,628 KB
testcase_40 AC 162 ms
80,492 KB
testcase_41 AC 164 ms
80,532 KB
testcase_42 AC 164 ms
80,668 KB
testcase_43 AC 167 ms
80,704 KB
testcase_44 AC 164 ms
80,708 KB
testcase_45 AC 165 ms
80,504 KB
testcase_46 AC 164 ms
80,532 KB
testcase_47 AC 167 ms
80,576 KB
testcase_48 AC 171 ms
80,432 KB
testcase_49 AC 164 ms
80,260 KB
testcase_50 AC 165 ms
80,512 KB
testcase_51 AC 161 ms
80,480 KB
testcase_52 AC 167 ms
80,556 KB
testcase_53 AC 167 ms
80,540 KB
testcase_54 AC 162 ms
80,580 KB
testcase_55 AC 165 ms
80,704 KB
testcase_56 AC 163 ms
80,596 KB
testcase_57 AC 161 ms
80,836 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 168 ms
80,664 KB
testcase_63 AC 169 ms
80,512 KB
testcase_64 WA -
testcase_65 AC 166 ms
80,564 KB
testcase_66 WA -
testcase_67 AC 163 ms
80,536 KB
testcase_68 WA -
testcase_69 AC 165 ms
80,484 KB
testcase_70 AC 163 ms
80,664 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 AC 165 ms
80,520 KB
testcase_74 AC 169 ms
80,660 KB
testcase_75 WA -
testcase_76 WA -
testcase_77 AC 163 ms
80,584 KB
testcase_78 AC 165 ms
80,672 KB
testcase_79 AC 168 ms
80,700 KB
testcase_80 WA -
testcase_81 AC 165 ms
80,776 KB
testcase_82 AC 165 ms
80,076 KB
testcase_83 AC 168 ms
80,184 KB
testcase_84 AC 167 ms
80,112 KB
testcase_85 AC 166 ms
80,264 KB
testcase_86 AC 167 ms
80,068 KB
testcase_87 AC 176 ms
80,152 KB
testcase_88 AC 178 ms
80,152 KB
testcase_89 AC 171 ms
80,268 KB
testcase_90 AC 167 ms
80,100 KB
testcase_91 AC 169 ms
80,204 KB
testcase_92 WA -
testcase_93 WA -
testcase_94 AC 165 ms
80,088 KB
testcase_95 AC 168 ms
80,076 KB
testcase_96 AC 168 ms
80,096 KB
testcase_97 AC 168 ms
80,240 KB
testcase_98 AC 168 ms
79,912 KB
testcase_99 AC 167 ms
80,284 KB
testcase_100 WA -
testcase_101 AC 164 ms
80,064 KB
testcase_102 AC 166 ms
80,088 KB
testcase_103 AC 165 ms
80,256 KB
testcase_104 AC 168 ms
80,344 KB
testcase_105 AC 168 ms
80,292 KB
testcase_106 AC 167 ms
80,272 KB
testcase_107 AC 166 ms
80,120 KB
testcase_108 AC 165 ms
80,368 KB
testcase_109 AC 170 ms
80,148 KB
testcase_110 AC 165 ms
80,176 KB
testcase_111 AC 166 ms
80,396 KB
testcase_112 AC 165 ms
79,904 KB
testcase_113 AC 164 ms
80,300 KB
testcase_114 AC 164 ms
80,200 KB
testcase_115 AC 164 ms
80,096 KB
testcase_116 AC 166 ms
80,072 KB
testcase_117 AC 166 ms
80,196 KB
testcase_118 AC 164 ms
80,304 KB
testcase_119 AC 167 ms
79,880 KB
testcase_120 AC 165 ms
80,120 KB
testcase_121 AC 165 ms
80,120 KB
testcase_122 AC 164 ms
80,484 KB
testcase_123 AC 167 ms
80,496 KB
testcase_124 AC 163 ms
80,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List, Tuple


def quadratic_solver(A: float, B: float, C: float) -> Tuple[int, List[float]]:
    """A*x^2 + B*x + C = 0

    返回解的个数和解的列表(-1表示无穷多个解)
    """
    if B < 0:
        A = -A
        B = -B
        C = -C
    if A == 0:
        if B == 0:
            if C == 0:
                return -1, []  # 无穷多个解
            return 0, []  # 无解
        return 1, [-C / B]

    D = B * B - 4 * A * C
    if D < 0:
        return 0, []
    if D == 0:
        return 1, [-B / (2 * A)]
    res1 = (-B - D**0.5) / (2 * A)
    res2 = C / A / res1
    if res1 > res2:
        res1, res2 = res2, res1
    return 2, [res1, res2]


if __name__ == "__main__":
    # https://yukicoder.me/problems/no/955%3E
    a, b, c = map(float, input().split())
    n, res = quadratic_solver(a, b, c)
    if n == -1:
        print(-1)
        exit(0)
    print(n)
    print(*res, sep="\n")
0