結果
問題 | No.2970 三次関数の絶対値 |
ユーザー |
![]() |
提出日時 | 2024-11-29 22:53:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 544 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 52,352 KB |
最終ジャッジ日時 | 2024-11-29 22:53:30 |
合計ジャッジ時間 | 3,683 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
from math import sqrtc0, c1, c2, c3 = map(int, input().split())l, r = map(int, input().split())def f(x):return c0 + x * (c1 + x * (c2 + x * c3))cand = [l, r]# c1+2c2x+3c3x^2a, b, c = 3 * c3, 2 * c2, c1if a == 0:if b:cand.append(-c / b)else:d = b * b - 4 * a * cif d >= 0:cand.append((-b + sqrt(d)) / (2 * a))cand.append((-b - sqrt(d)) / (2 * a))res = [f(x) for x in cand if l <= x <= r]mn = min(res)mx = max(res)ans = 0 if mn <= 0 <= mx else min(abs(mn), abs(mx))print(f'{ans:.10f}')