2654. Median

单点时限: 2.0 sec

内存限制: 256 MB

This problem is easy. You are giving $N$ numbers, and you are going to find the Median of them. Median is the number that separates the higher half the numbers given from the lower half.

输入格式

There are some cases. Process to the end of file

Each case give as $N,A,X_0,B,M$ separates by a single space, and you are going to generate the numbers as follow:

$X_i = (X_{i-1} \cdot A + B) \bmod M$

$N$ would be less than $1~000~000$. Both $A, B, M, X_i$ would be a positive number less than $40000$.

输出格式

Output the number which is the median of the sequence in one line. If $N$ is even,you should output the second of the two medians.

样例

Input
5 73 5 97 43
Output
25

35 人解决,55 人已尝试。

66 份提交通过,共有 286 份提交。

5.0 EMB 奖励。

创建: 15 年,4 月前.

修改: 7 年,2 月前.

最后提交: 1 年,5 月前.

来源: N/A

题目标签