結果

問題 No.1179 Quadratic Equation
ユーザー fuppy_kyoprofuppy_kyopro
提出日時 2020-08-21 21:43:09
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 528 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-10-15 05:27:56
合計ジャッジ時間 1,241 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import decimal
from decimal import Decimal

def main():
    A, B, C = map(int, input().split())
    if A < 0:
        A *= -1
        b *= -1
        C *= -1
    a = Decimal(A)
    b = Decimal(B)
    c = Decimal(C)


    k = b * b - Decimal(4) * a * c
    if k < Decimal(0):
        print("imaginary")
        return

    if k == 0:
        print(-b / (Decimal(2) * a))
    else:
        print((-b - k.sqrt()) / (Decimal(2) * a), end=' ')
        print((-b + k.sqrt()) / (Decimal(2) * a))


if __name__ == '__main__':
    main()
0