The Problem of Train Setout

At a railway station there is only one out channel. There are two kinds of trains : the express train and ordinary train. The ordinary train should wait to setout until all the express train have setout. But if an ordinary train is just setouting, the incoming express train should wait until the ordinary train leaves. The leaving time of express train and ordinary train are Le and Lo. And the time between the arriving of two express train is Ae and of ordinary train is Ao. The total observation time is T. You should work out a program to illustrate the number of trains waiting to setout at any time, and calculate the average time of the two kinds of trains waiting We, Wo, and the average time of the all trains waiting Wt, and the time every train waited W(t). Assume that the setout channel is empty at first and a express train comes first. And the output channel will never be empty. Input The input is a number of lines of five numbers that represent Ae,Ao,Le,Lo,T respectively. The last line of input contains five 0’s. This line should not be processed. Output For each input line, the first part of the output is an array of the waiting trains, one element per line. There are three numbers in a line. First is the time, second is the number of waiting express trains, the third is the number of waiting ordinary trains. Only print the triples when the number of waiting express trains and number of waiting ordinary trains is unique. At the end of the array, there is a ‘0’. After the array, there is a line contains three numbers are We,Wo,Wt. This is followed by a line containing only one ‘0’. The last part of the output is also an array, one element per line. There are two elements per line. The first one is the train. If the train is an express train, then the first element begins with ‘E’, followed by the number of the express train, (the number is according to the incoming order of the train); else it begins with ‘O’, followed by the number of the ordinary train. The second is the time the train has waited. Separate the output for each input line with a single blank line. Sample Input 3 6 6 2 30 67758 00000 Sample Output 000 310 611 921 12 2 2 15 3 2 18 3 3 21 4 3

2/2 24 4 4 27 5 4 30 5 5 0 6 12 8 0 E1 0 E2 3 E3 6 E4 9 E5 12 E6 15 E7 12 E8 9 E9 6 E10 3 E11 0 O1 24 O2 18 O3 12 O4 6 O5 0 000 610 701 0 010 0 E1 0 E2 1 O1 1