Trains

Two towns T1 and T2 are connected through a double railroad. The distance between T1 and T2 is d meters. From T1 to T2 the trains are leaving every t1 seconds. From T2 to T1 the trains are leaving every t2 seconds. The trains from T1 to T2 have a speed of v1 m/s. The trains from T2 to T1 have a speed of v2 m/s. Your task is to write a program that computes the number of train “rendezvous” on the railroad which links T1 and T2, and which occur during the time interval [0, tf ] seconds. We consider that: a) at time 0 two trains are leaving (from T1 to T2, and from T2 to T1); b) the input and output data are integers. Input Your program reads data sets, one per line, in the following format: dv1 v2 t1 t2 tf. Output The program writes to the output the number of “rendezvous”. Sample Input 10 5 5 1 1 2 Sample Output 6