問題一覧 > 教育的問題

No.2970 Absolute Value of a Cubic Function

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-3}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 49
作問者 : 👑 p-adic / テスター : Moss_Local
お気に入りにしたユーザー ProblemId : 10914 / 自分の提出
問題文最終更新日: 2024-08-18 09:58:58
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 454 (順位表) の他の問題:

Problem Statement

You are given $6$ integers $C_0, C_1, C_2, C_3, L, R$ satisfying $L \leq R$.

 

Find the minimum value of $|C_0 + C_1 x + C_2 x^2 + C_3 x^3|$ over all real numbers $x$ satisfying $L \leq x \leq R$:

$\displaystyle \min_{L \leq x \leq R} |C_0 + C_1 x + C_2 x^2 + C_3 x^3| $

It can be proved that the minimum value exists.

Input

The input is given from Standard Input in $2$ lines in the following format:

  • The $1$st line contains $C_0, C_1, C_2, C_3$, separated by single-byte spaces.
  • The $2$nd line contains $L, R$, separated by single-byte spaces.
$C_0$ $C_1$ $C_2$ $C_3$
$L$ $R$

Constraints

The input satisfies the following constraints:

  • $C_0$ is an integer satisfying $-10 \leq C_0 \leq 10$.
  • $C_1$ is an integer satisfying $-10 \leq C_1 \leq 10$.
  • $C_2$ is an integer satisfying $-10 \leq C_2 \leq 10$.
  • $C_3$ is an integer satisfying $-10 \leq C_3 \leq 10$.
  • $L$ and $R$ are integers satisfying $-10 \leq L \leq R \leq 10$.

Output

Output on $1$ line the minimum value of $|C_0 + C_1 x + C_2 x^2 + C_3 x^3|$ over all real numbers $x$ satisfying $L \leq x \leq R$:

$\displaystyle \min_{L \leq x \leq R} |C_0 + C_1 x + C_2 x^2 + C_3 x^3| $

Print a newline at the end.

 

Note that this problem allows for decimal errors. Your answer is judged correct if its absolute or relative error from the approximation to $6$ decimal places of the exact answer is at most $10^{-3}$.

Here, the approximation to $6$ decimal places of a real number $x$ means the largest real number not exceeding $x$ that has a finite decimal representation with at most $6$ digits after the decimal point.

Also, due to the judge's constraints, your output must be fewer than $500$ digits long.

Sample

Sample 1
Input
0 0 0 0
0 0
Output
0.000000

Let $f(x) = C_0 + C_1 x + C_2 x^2 + C_3 x^3 = 0 + 0x + 0x^2 + 0x^3$. Since $|f(x)|$ takes only the value $0$ on the interval $[L,R] = [0,0]$, we have

$\displaystyle \min_{L \leq x \leq R} |f(x)| = 0 $

.

Sample 2
Input
0 -1 0 0
1 2
Output
1.000000

Let $f(x) = C_0 + C_1 x + C_2 x^2 + C_3 x^3 = -x$. Since $|f(x)| = |x|$ equals $x$ and is strictly increasing on the interval $[L,R] = [1,2]$, we have

$\displaystyle \min_{L \leq x \leq R} |f(x)| = |f(L)| = 1 $

.

Sample 3
Input
1 0 1 0
-1 1
Output
1.000000

Let $f(x) = C_0 + C_1 x + C_2 x^2 + C_3 x^3 = 1+x^2$. Since $|f(x)| = 1+x^2$ is convex on the interval $[L,R] = [-1,1]$ and attains its minimum at $x = 0$, we have

$\displaystyle \min_{L \leq x \leq R} |f(x)| = |f(0)| = 1 $

.

Sample 4
Input
0 0 0 1
-1 2
Output
0.000000

Let $f(x) = C_0 + C_1 x + C_2 x^2 + C_3 x^3 = x^3$. Since $|f(x)| = |x^3|$ has a zero (a solution of the equation $|f(x)| = 0$) $x = 0$ on the interval $[L,R] = [-1,2]$, we have

$\displaystyle \min_{L \leq x \leq R} |f(x)| = 0 $

.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。