
ZOJ Problem Set  1338
The quality of pseudo randomnumber generators used in some computations, especially simulation, is a significant issue. Proposed generation algorithms are subjected to many tests to establish their quality, or, more usually, their lack of it. One of the common tests is the run test. In this test, sequences are tested for ``runs up" and ``runs down." We will examine series of data values for the ``Up" and ``Down" sequences each series contains. Within a series, an ``Up" sequence continues as long as each datavalue received is not less than the previous datavalue. An ``Up" sequence terminates when a datavalue received is less than the previous datavalue received. A ``Down" sequence continues as long as each datavalue received is not greater than the previous datavalue. A ``Down" sequence terminates when a datavalue received is greater than the previous datavalue received. An ``Up" sequence can be initiated by the termination of a ``Down" sequence and vice versa. (Sequences initiated in this manner have length one at this initiation point.) All the initial datavalues are part of an ``Up" sequence, and contribute to its length, if the first deviation of the datavalues is upwards. All the initial datavalues are part of a ``Down" sequence, and contribute to its length, if the first deviation of the datavalues is downwards. If the datavalues received don't allow classification as either an ``Up" or a ``Down" sequence, the data should be considered to have neither sequence. Find the average length of both the ``Up" and the ``Down" sequences encountered for each input line in the data file. Report these average lengths as each input line is processed.
Each series to be analyzed consists of at least one and no more than 30 unsigned, nonzero integers. Each integer in a series has at least one digit and no more than four digits. The integers are separated from each other by a single blank character. Each of the series will be terminated by a single zero (0) digit. This terminator should not be considered as being part of the series being analyzed. The set of series to be analyzed is terminated by a single zero (0) digit as the input on a line. This terminator should not be considered to be a series, and no output should be produced in response to its encounter.
First, the average ``Up" run length, then the average ``Down" run length. Separate these values with a space. Answers must be rounded to six digits after the decimal point.
1 2 3 0 Sample Output Nr values = 3: 2.000000 0.000000 Source: East Central North America 1995 