Travel optimization P62842


Statement
 

pdf   zip

Consider a two-dimensional world with no obstacles. You must go from point AA to point BB, and then return to AA. When traveling, you can either walk or take the train. There are only two train stations, CC and DD, 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 UU, 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 A,B,CA, B, C and DD, the walking speed WW, the train speed TT, and the constant UU, can you compute the minimum expected time to go from AA to BB, and from BB to AA, assuming a perfect strategy?

Input

Input consists of several cases with real numbers, each with the coordinates of A,B,CA, B, C and DD, followed by WW, TT, and UU. Assume T>W>0T > W > 0 and U>0U > 0.

Output

For each case, print the expected time to go from AA to BB, and to go from BB to AA, both with four digits after the decimal point. The input cases have no precision issues.

Public test cases
  • 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
    
  • Information
    Author
    Ivan Geffner
    Language
    English
    Official solutions
    C++
    User solutions
    C++