結果
| 問題 |
No.2970 三次関数の絶対値
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-29 21:50:46 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 632 bytes |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-11-29 21:50:49 |
| 合計ジャッジ時間 | 3,130 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 WA * 17 |
ソースコード
from math import sqrt
C = list(map(int, input().split()))
L, R = map(int, input().split())
def func(x):
y = 0.0
a = 1.0
for i in range(4):
y += C[i] * a
a *= x
return y
Y = [func(L), func(R)]
D = [i * C[i] for i in range(1, 4)]
if C[3] and D[1] * D[1] - 4 * D[0] * D[2] > 0:
l = (-D[1] - sqrt(D[1] * D[1] - 4 * D[0] * D[2])) / (2 * D[2])
r = (-D[1] + sqrt(D[1] * D[1] - 4 * D[0] * D[2])) / (2 * D[2])
Y.append(func(l))
Y.append(func(r))
elif C[2]:
m = -D[0] / D[1]
Y.append(func(m))
if max(Y) < 0:
print(-max(Y))
elif min(Y) > 0:
print(min(Y))
else:
print(0)