Chase in a circle
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
A cat is chasing a mouse inside a round building. The cat and the mouse can only run along the edge of the circle and cannot step inside the circle or go outside its boundaries.
The mouse runs at a speed of at most \(b\). The cat has two modes — resting and running at a speed of at most \(a\). The cat can change its mode an arbitrary number of times. Also, it is guaranteed that the cat is faster than the mouse when running (\(a > b\)). There is a restriction on the time the cat can run. At any moment in time, if the cat has rested for a total of \(t\) seconds, then it has run for a total of no more than \(t\) seconds.
For example, the following 2 sequences of cat mode changes are valid:
resting for 1 second, running for 1 second, resting for 3 seconds, running for 2 seconds;
resting for 5 seconds, running for 1 second, resting for 0.5 seconds, running for 4.47 seconds.
The following sequence is not valid because at time moment \(T = 4.5\) the cat had rested and run for 2 and 2.5 seconds respectively (\(2 < 2.5\)):
resting for 1 second, running for 1 second, resting for 1 second, running for 2 seconds.
You are given the circumference of the circle and the length of the circular arc between the initial positions of the cat and the mouse. A circular arc is a part of the circle bounded by two points. At any moment in time, both the cat and the mouse can see where their opponent is. Find the minimum time in which the cat can catch the mouse, if the mouse runs away optimally.
Input
The single line contains 4 real numbers \(l, d, a, b\) — the circumference of the circle, the length of the arc between the initial positions of the cat and the mouse, the cat’s speed, and the mouse’s speed. Each of the numbers is given with 5 decimal places.
Output
In a single line, output a single number representing the minimum time in which the cat can catch the mouse. The absolute or relative error must not exceed \(10^{-7}\). It is guaranteed that the answer exists and does not exceed \(10^9\).
Constraints
\(0 < b < a < 10^3\),
\(0 < l < 10^3\),
\(0 < d \le 0.5 \cdot l\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 10.00000 1.00000 4.00000 1.00000 | 1 |
| Input (stdin) | Output (stdout) |
|---|---|
| 12.00000 5.00000 2.50000 1.00000 | 8.0 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|