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:

Input and Output 

The program reads sets of data from a text file. Each data set is on a separate line and has the format: $d\ d_1\ d_2\ v_1\ v_2\
t_1\ t_2\ t_i\ t_f$. The input data are correct. 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
2 1 1 1 1 1 1 0 1
3 2 1 1 1 1 1 0 0
3 2 1 1 1 1 1 1 1
3 2 1 1 1 1 1 0 1
6525 100000 55000 22 33 3 4 -10000 -3600

Sample Output 

10
4
2
2
7
263450



Miguel Revilla
2001-01-05