← 返回 microsoft 的题目列表Find Vertex of a Quadratic Function Within a Range
类型:online_judge
Given a quadratic function f(x) = ax^2 + bx + c with a != 0, and a closed interval [L, R]. It is guaranteed that the vertex x-coordinate lies within [L, R].
Return the x-coordinate of the vertex x_v. Print it as a floating-point number.
Input
One line with 5 numbers: a b c L R.
Output
One line: the vertex x-coordinate x_v.
Constraints
a, b, c, L, R are real numbers
L <= R
x_v = -b / (2a) satisfies L <= x_v <= R
Example
Input:
1 -4 3 0 10
Output:
2.0
Example
Input
1 -4 3 0 10
Output
2.0