F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Median

Time Limit: 10000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 660    Accepted Submission(s): 94


Problem Description
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.
 

Input
There are some cases. Process to the end of file.
Each case given as N A X0 B M separates by a single space, and you are going to generate the numbers as following:
  Xi = (Xi-1 * A + B) mod M
N would be less than 1000000 Both A, B, M and Xi would be a positive number less than 40000.
 

Output
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.
 

Sample Input
5 73 5 97 43
 

Sample Output
25
 

Author
ZSTU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-03 16:23:21, Gzip enabled