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}.
To its right, on the second rail and *d* distance units apart,
there is a train of length ℓ_{2}.
This simple picture corresponds to all the cases of the sample input,
with ℓ_{1} = 10, ℓ_{2} = 20 and *d* = 30:

unit=0.2cm

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

linewidth=2pt linecolor=blue (05,04)(15,04) (45,04)(65,04)

linestyle=dotted linewidth=1pt linecolor=red <-(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 *v*_{1} and constant acceleration *a*_{1}.
The second train has velocity *v*_{2} and constant acceleration *a*_{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}, ℓ_{2}, *d*, *v*_{1}, *a*_{1}, *v*_{2} and *a*_{2}.
Assume that ℓ_{1}, ℓ_{2} and *d* are strictly positive.
No number is larger than 10^{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++