結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー 👑 cologne
提出日時 2026-10-23 12:50:51
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,253 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 88 ms
コンパイル使用メモリ 64,608 KB
実行使用メモリ 62,644 KB
最終ジャッジ日時 2026-10-23 12:51:14
合計ジャッジ時間 13,294 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 103 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys

from decimal import Decimal, localcontext

from typing import List, Tuple

int1 = lambda x: int(x) - 1
input = lambda: sys.stdin.readline().rstrip('\n')
ii = lambda: int(input())
vi = lambda: list(map(int, input().split()))
vi1 = lambda: list(map(int1, input().split()))


def dbg(*args, **kwargs):
    print(*(repr(arg) for arg in args), *(f'{k}: {repr(v)}' for k, v in kwargs.items()),
          sep='; ', file=sys.stderr, flush=True)


def main():
    a, b, c = vi()

    if a == 0:
        if b == 0:
            if c == 0:
                print(-1)
            else:
                print(0)
        else:
            print(1, -c / b, sep='\n')
    else:
        D = b * b - 4 * a * c
        if D == 0:
            print(1, -b / (2 * a), sep='\n')
        elif D < 0:
            print(0)
        else:
            with localcontext() as ctx:
                ctx.prec = 100
                sqrtD = Decimal.sqrt(Decimal(D))
                s1 = (-b - sqrtD) / (2 * a)
                s2 = (-b + sqrtD) / (2 * a)
                print(2, s1, s2, sep='\n')


def _start():
    if (ret := main()) is not None:
        print(*ret) if isinstance(ret, List) or isinstance(ret, Tuple) else print(ret)


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