Two trains P90619


Statement
 

pdf   zip

Consider two infinite horizontal train rails, so close that we can regard them to be coincident. On the first rail there is a train of length 1\ell_1. To its right, on the second rail and dd distance units apart, there is a train of length 2\ell_2. This simple picture corresponds to all the cases of the sample input, with 1=10\ell_1 = 10, 2=20\ell_2 = 20 and d=30d = 30:

(70,10) (10,06)10 (30,04)30 (55,06)20

(05,04)(15,04) (45,04)(65,04)

(05,06)(09,06) (11,06)(15,06) (15,04)(29,04) (31,04)(45,04) (45,06)(54,06) (56,06)(65,06)

The first train has velocity v1v_1 and constant acceleration a1a_1. The second train has velocity v2v_2 and constant acceleration a2a_2. Positive means to the right, negative means to the left. For how many time units will the trains overlap, at least partially?

Input

Input consists of several cases, with only integer numbers, each one with 1\ell_1, 2\ell_2, dd, v1v_1, a1a_1, v2v_2 and a2a_2. Assume that 1\ell_1, 2\ell_2 and dd are strictly positive. No number is larger than 10410^4 in absolute value.

Output

For every case, print with four digits after the decimal point the amount of time that both trains will overlap. The input cases have no precision issues.

Public test cases
  • Input

    10 20 30 10 0 20 0
    10 20 30 10 0 -10 5
    10 20 30 10 0 -10 1
    10 20 30 10 0 -10 -10
    

    Output

    0.0000
    4.0000
    3.4118
    0.8377
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++