#P1258. Optimal Car Assistance for Synchronized Arrival

    ID: 14545 Type: Default 1000ms 256MiB

Optimal Car Assistance for Synchronized Arrival

Optimal Car Assistance for Synchronized Arrival

Two people, A and B, depart simultaneously from point A and need to reach point B as quickly as possible, arriving at exactly the same time. Initially, there is a car at A; however, the car, besides the driver, can only carry one additional person. Both persons walk at the same speed \(v\) (with \(v > 0\)), and the car moves faster at speed \(u\) (with \(u > v\)).

The strategy is as follows:

  1. Person A rides the car from A to a turnaround point \(L\), while person B starts walking from A toward B.
  2. At point \(L\), person A gets out. The car immediately turns back to pick up person B, who is still walking.
  3. The car meets person B on the road; then, person B boards the car and is driven to B. Meanwhile, person A continues walking from \(L\) to B.

To ensure that both persons arrive at B simultaneously and in minimal time, the optimal turnaround point \(L\) satisfies the condition that the arrival time of person A (walking from \(L\)) equals the total time for person B (the sum of the time until the car meets B and the time from that point to B in the car).

It can be shown that the optimal \(L\) is given by:

[ L = \frac{(u^2 - v^2)D}{u^2 + 3uv - 2v^2}, ]

and the minimal total time \(T\) for both persons to reach B is:

[ T = \frac{D - L}{v}. ]

Given the distance \(D\) from A to B, walk speed \(v\) and car speed \(u\) (with \(u > v > 0\)), compute the minimal time \(T\) (in seconds) for both persons to arrive at point B simultaneously under the optimal strategy. Output the time with 6 decimal places.

inputFormat

The first line contains an integer \(T\) (the number of test cases). Each of the next \(T\) lines contains three positive real numbers: \(D\) (the distance from A to B), \(v\) (walking speed) and \(u\) (car speed), where \(u > v\).

outputFormat

For each test case, output the minimal time \(T\) required for both persons to reach B simultaneously, accurate to 6 decimal places.

sample

4
100 1 2
200 3 6
150 2 5
1000 10 20
62.500000

41.666667 41.489362 62.500000

</p>