結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
![]() |
提出日時 | 2020-12-09 17:30:50 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 979 bytes |
コンパイル時間 | 209 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-09-19 01:19:14 |
合計ジャッジ時間 | 6,653 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 122 |
ソースコード
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)