Consider a two-dimensional world with no obstacles. You must go from point to point , and then return to . When traveling, you can either walk or take the train. There are only two train stations, and , with trains going in both directions. On the outside, stations have a public timer displaying the time until the next train. When looking at the timer, you can decide to either wait for the next train, or to walk to your destination. Assume that the time displayed when arriving at a station follows a uniform distribution from 0 to , and that there is no correlation between the schedule of the trains in the two directions. Suppose that it takes no time to enter or leave a train.
Given the positions of the four differents points and , the walking speed , the train speed , and the constant , can you compute the minimum expected time to go from to , and from to , assuming a perfect strategy?
Input consists of several cases with real numbers, each with the coordinates of and , followed by , , and . Assume and .
For each case, print the expected time to go from to , and to go from to , both with four digits after the decimal point. The input cases have no precision issues.
Input
0 0 10 0 0 30 10 30 1 4 2 0 0 10 0 0 2 10 2 1 4 2 3 3 1 0 0 2 4 1 1 2 1000 0.2 -42.23 10.2 -42.23 2.2 -42.23 12.2 -42.23 2.5 8.9 4.3
Output
10.0000 10.0000 7.5000 7.5000 3.6056 3.6056 3.8106 4.0000