結果

問題 No.2970 三次関数の絶対値
ユーザー PNJ
提出日時 2024-11-29 22:40:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 619 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 54,680 KB
最終ジャッジ日時 2024-11-29 22:40:59
合計ジャッジ時間 3,854 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c, d = map(int, input().split())
L, R = map(int, input().split())

def f(x):
  return a + b * x + c * x * x + d * x * x * x

ans = [f(L), f(R)]

if d != 0:
  p = (c * c / (3 * d)) - b
  if p == 0:
    x = -c / (3 * d)
    if L <= x <= R:
      ans.append(f(x))
  elif p > 0:
    p /= (3 * d)
    p = p ** 0.5
    x, y = p - c / (3 * d), -p - c / (3 * d)
    if L <= x <= R:
      ans.append(f(x))
    if L <= y <= R:
      ans.append(f(y))

else:
  if c != 0:
    x = -b / (2 * c)
    if L <= x <= R:
      ans.append(f(x))

m, M = min(ans), max(ans)

if m * M <= 0:
  print(0)
else:
  print(min(abs(m), abs(M)))
0