F. F128
time limit per test
0.25 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Passinho is having an existential crisis. After yet another tough F128 class at Unicamp, he wonders, indignantly, why computer science students need to study physics. "All I wanted was to dance and code... and now I'm stuck with this problem!" he laments.

This time, Passinho needs to understand the motion of a particle confined in a straight, closed corridor.

Consider a particle moving in a straight corridor of total length $$$d$$$ meters, with perfectly rigid walls at both ends. We define the position $$$x$$$ of the particle as the distance in meters from the leftmost wall of the corridor. The particle starts from an initial point at a distance $$$k$$$ meters from this wall, with an initial velocity of $$$v$$$ meters per second (positive, i.e., directed to the right), and moves for a total time of $$$t$$$ seconds.

Whenever the particle collides with one of the ends of the corridor (at positions $$$x = 0$$$ and $$$x = d$$$), it reverses its direction of motion and loses kinetic energy. This causes its velocity to be multiplied by a loss factor $$$\lambda$$$, where $$$0 \lt \lambda \lt 1$$$. That is, after the first collision, its velocity becomes $$$v \cdot \lambda$$$; after the second, $$$v \cdot \lambda^2$$$; and so on.

Since Passinho only wants to code, help him by writing a program that calculates the exact position of the particle after $$$t$$$ seconds. Do this before he decides to drop the course for good!

Input

The first line of input contains four integers $$$d$$$, $$$t$$$, $$$k$$$, and $$$v$$$, representing, respectively, the length of the corridor, the total time of the experiment, the initial position of the particle, and its initial velocity.

  • $$$1 \leq d \leq 10^4$$$
  • $$$0 \leq t \leq 10^4$$$
  • $$$0 \leq k \lt d$$$
  • $$$0 \leq v \leq 10^4$$$

The second line contains a single real number $$$\lambda$$$ ($$$0 \lt \lambda \lt 1$$$), with exactly 4 decimal places, representing the velocity loss factor at each collision.

Output

Print a single real number $$$X$$$, representing the final position of the particle after $$$t$$$ seconds of movement.

Your answer will be considered correct if the absolute or relative error does not exceed $$$10^{-6}$$$.

More formally, your answer $$$a$$$ will be accepted if and only if $$$\frac{|a - b|}{\max(1, |b|)} \leq 10^{-6}$$$, where $$$b$$$ is the jury's correct answer.

Examples
Input
8 4 2 1
0.0010
Output
6.000000
Input
8 10 1 1
0.5
Output
6.500000
Input
10 40 5 3
0.3
Output
7.350000
Note

Hint: To avoid numerical precision issues, you can configure your program's output to print more decimal places:

  • In C++: use cout « fixed « setprecision(10);
  • In C: use printf("%.10lf", x);
  • In Python: use print(f"{x:.10f}")