結果
| 問題 | No.2970 三次関数の絶対値 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-30 03:14:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,582 ms / 2,000 ms |
| コード長 | 480 bytes |
| 記録 | |
| コンパイル時間 | 299 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 68,124 KB |
| 最終ジャッジ日時 | 2024-11-30 03:16:10 |
| 合計ジャッジ時間 | 76,506 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
| 外部呼び出し有り |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
# https://mirucacule.hatenablog.com/entry/2021/09/14/183909
import numpy as np
from scipy.optimize import minimize
c0, c1, c2, c3 = map(int, input().split())
l, r = map(int, input().split())
def f(x):
return abs(c0 + c1 * x + c2 * x**2 + c3 * x**3)
div = 100
x = np.linspace(l, r, div)
y = f(x)
x0 = l + ((r - l) / div) * (np.argmin(y) + 1) # initial point
bnds = ((l, r),)
res = minimize(f, x0, method='Nelder-Mead', bounds=bnds, tol=1e-5)
print('{:f}'.format(res.fun))