結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
![]() |
提出日時 | 2020-12-09 17:05:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,196 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 80,512 KB |
最終ジャッジ日時 | 2024-09-19 01:16:37 |
合計ジャッジ時間 | 5,559 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 TLE * 1 -- * 90 |
ソースコード
import sys 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() if a == 0: if b != 0: print(1) print(-c/b) else: if c == 0: print(-1) else: print(0) elif b**2 > 4*a*c: if a < 0: a,b,c = -a,-b,-c e = 10**-11 pos = -10**10 neg = -b/(2*a) while neg-pos >= e: mid = (pos+neg)/2 if a*mid**2+b*mid+c > 0: pos = mid else: neg = mid sol0 = pos pos = 10**10 neg = -b/(2*a) while pos-neg >= e: mid = (pos+neg)/2 if a*mid**2+b*mid+c > 0: pos = mid else: neg = mid sol1 = pos print(2) print(sol0) print(sol1) elif b**2 == 4*a*c: print(1) print(-b/(2*a)) else: print(0)