This problem is also easy.
Given N numbers, and please find the Median of them. Median is the number which separates the higher half the numbers given from the lower half.
There are some cases. Process to the end of file.
Each case given as N A X
0 B M separates by a single space, and you are going to generate the numbers as following:
X
i = (X
i-1 * A + B) mod M
N would be less than 1000000 Both A, B, M and X
i would be a positive number less than 40000.
Output the number which is the median of the sequence.
If there are even numbers,please select the later, and one line for one case.