Two Way Traffic

A motorway is passing through a tunnel, d meters long, as illustrated in figure 1. The rate of the traffic directed eastwards is of one vehicle every t1 seconds, and the rate of the traffic directed westwards is of one vehicle every t2 seconds. The vehicles going east have a constant speed of v1 m/s, while the vehicles going west have a constant speed of v2 m/s. Figure 1: The motorway Write a program that computes the number of vehicle ‘rendezvous’ that occur inside the tunnel during the closed time interval [ti,tf] that is measured in seconds. It is known that: • A rendezvous point is considered inside the tunnel if it is in between the entrances of the tunnel. Rendezvous at the tunnel entrances are outside the tunnel, as shown in figure 1. • At time 0 there is a vehicle advancing eastwards that is d1 meters away from the entrance of the tunnel, and there is another vehicle advancing westwards that is d2 meters away from the entrance of the tunnel. These vehicles are part of the already existing traffic on the motorway. • Input and output data are integers. The magnitude range of the problem parameters is as follows: 0 ≤ d,d1,d2 ≤ 100000, 0 < t1,t2 ≤ 10000, −10000 ≤ ti,tf ≤ 10000. Input The program reads sets of data from a text file. Each data set is on a separate line and has the format: d d1 d2 v1 v2 t1 t2 ti tf. The input data are correct. Output For each data set the program writes to the standard output the number of rendezvous. Each result is on a separate line. An example of program input/output for six data sets is shown in the sample below. Sample Input 1 0 0 1 1 1 1 0 10 211111101 321111100 321111111 321111101 6525 100000 55000 22 33 3 4 -10000 -3600

2/2 Sample Output 10 4 2 2 7 263450