結果

問題 No.2970 三次関数の絶対値
ユーザー vwxyz
提出日時 2024-11-29 21:40:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 416 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-29 21:40:41
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b,c,d=map(int,input().split())
L,R=map(int,input().split())
def f(x):
    return abs(a+b*x+c*x*x+d*x*x*x)
ans=min(f(L),f(R),f(0))
eps=1e-7
if d:
    if c*c-3*b*d>=0:
        D=c*c-3*b*d
        for i in ((-c+D**.5)/(3*d),(-c-D**.5)/(3*d)):
            if L-eps<=i<=R+eps:
                ans=min(ans,f(i))
else:
    if c:
        i=(-b)/(2*c)
        if L-eps<=i<=R+eps:
            ans=min(ans,f(i))
print(ans)


0