Module: Linear enumeration


Problem

1 /5


Arg minimum of a quadratic function

Theory Click to read/hide

It is often difficult to find the optimal parameter analytically. In this case, if temporary resources allow, you can go through all the possible options, see how good they are and choose the best one.

Problem

You are given a function f(x) = a*x2 + b*x + c (a, b and c can all be zero).
Find such a minimum integer x that among all integer arguments in the segment [l;r] the value of the function f is the minimum possible.

Input:
The first line gives you the coefficients of the equation a, b, c. They are integers and -100 <= a, b, c <= 100.
The second line contains the boundaries of the segment l and r, within which it is necessary to search for the minimum of the function. They are integers and -100 <= l <= r <= 100.

Output:
Print the argument where the minimum is reached on the segment. At the same time, it should be as small as possible.

Example:
 
Input Output
-1 0 1
-4 4
-4