| UNICAMP Freshman Contest 2025 |
|---|
| Закончено |
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!
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.
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.
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.
8 4 2 10.0010
6.000000
8 10 1 10.5
6.500000
10 40 5 30.3
7.350000
Hint: To avoid numerical precision issues, you can configure your program's output to print more decimal places:
| Название |
|---|


