Watermelons
Hard
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
n watermelons lie in a row on the counter. It is known that each watermelon, except the first and the last, is 100 grams lighter than the arithmetic mean of weight of their neighbors.
Find the weight of the m - th watermelon to the nearest gram if the weights of the first and last watermelon are known.
Input
One line contains four numbers:
n (2 ≤ n ≤ 10000) - the number of watermelons,
a, b - the weight of the first and the last watermelon in kilograms (positive real numbers, 0 < a, b ≤
10^9
),m - the number of the watermelon which weight should be found (integer, 1 ≤ m ≤ n).
Output
Print the weight of the m - th watermelon in kilograms accurate to the thousandths, or -1 if the problem has no solution.
Examples
Input #1
Answer #1
Submissions 666
Acceptance rate 9%