結果
| 問題 | No.955 ax^2+bx+c=0 |
| コンテスト | |
| ユーザー |
ayaoni
|
| 提出日時 | 2020-12-09 17:30:50 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 28 ms / 2,000 ms |
| + 499µs | |
| コード長 | 979 bytes |
| 記録 | |
| コンパイル時間 | 59 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2026-10-19 21:36:08 |
| 合計ジャッジ時間 | 7,796 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 123 |
ソースコード
import sys
from math import sqrt
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())
a,b,c = MI()
D = b**2-4*a*c
if a == 0:
if b != 0:
print(1)
print(-c/b)
else:
if c == 0:
print(-1)
else:
print(0)
elif D > 0:
if a < 0:
a,b,c = -a,-b,-c
if b > 0:
sol0 = (-b-sqrt(D))/(2*a)
sol1 = c/(a*sol0)
else:
sol0 = (-b+sqrt(D))/(2*a)
sol1 = c/(a*sol0)
print(2)
print(min(sol0,sol1))
print(max(sol0,sol1))
elif D == 0:
print(1)
print(-b/(2*a))
else:
print(0)
ayaoni