結果
| 問題 |
No.1179 Quadratic Equation
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2020-08-21 21:40:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,926 bytes |
| コンパイル時間 | 213 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 52,864 KB |
| 最終ジャッジ日時 | 2024-10-15 05:26:03 |
| 合計ジャッジ時間 | 1,405 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 2 |
ソースコード
def General_Binary_Increase_Search(L,R,cond,Integer=True,ep=1/(1<<20)):
"""条件式が単調増加であるとき,一般的な二部探索を行う.
L:解の下限
R:解の上限
cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
Integer:解を整数に制限するか?
ep:Integer=Falseのとき,解の許容する誤差
"""
if not(cond(R)):
return False
if Integer:
R+=1
while R-L>1:
C=L+(R-L)//2
if cond(C):
R=C
else:
L=C
return R
else:
while (R-L)>=ep:
C=L+(R-L)/2
if cond(C):
R=C
else:
L=C
return R
def General_Binary_Decrease_Search(L,R,cond,Integer=True,ep=1/(1<<20)):
"""条件式が単調減少であるとき,一般的な二部探索を行う.
L:解の下限
R:解の上限
cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
Integer:解を整数に制限するか?
ep:Integer=Falseのとき,解の許容する誤差
"""
if not(cond(L)):
return False
if Integer:
L-=1
while R-L>1:
C=L+(R-L)//2
if cond(C):
L=C
else:
R=C
return L
else:
while (R-L)>=ep:
C=L+(R-L)/2
if cond(C):
L=C
else:
R=C
return L
#==========================================================
from math import sqrt
a,b,c=map(int,input().split())
D=b*b-4*a*c
if D>0:
p=General_Binary_Decrease_Search(-10*100,-b/(2*a),lambda x:a*x**2+b*x+c>=0,False,10**(-10))
q=General_Binary_Increase_Search(-b/(2*a),10**100,lambda x:a*x**2+b*x+c>=0,False,10**(-10))
print(p,q)
elif D==0:
print(-b/(2*a))
else:
print("imaginary")
Kazun