結果
| 問題 | No.2970 三次関数の絶対値 |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2024-11-29 22:53:26 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 34 ms / 2,000 ms |
| + 99µs | |
| コード長 | 544 bytes |
| 記録 | |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 64,732 KB |
| 実行使用メモリ | 54,044 KB |
| 最終ジャッジ日時 | 2026-10-23 12:41:04 |
| 合計ジャッジ時間 | 4,341 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 51 |
ソースコード
from math import sqrt
c0, 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^2
a, b, c = 3 * c3, 2 * c2, c1
if a == 0:
if b:
cand.append(-c / b)
else:
d = b * b - 4 * a * c
if 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}')
Kude