![]() | ||||
Online Judge | Problem Set | Authors | Online Contests | User |
---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
National Day Celebration Time Limit:2000MS Memory Limit:65536K Description
It is 100 years since the country was founded, and the king decides to hold an activity, which is described below, to celebrate this National Day. The king and N soldiers make up a circle, and from a random chosen man, the N+1 persons are numbered from 1 to N+1 (the mans numbered with i and i+1 (1 <= i <= N) are neighboring, and the man numbered with N+1 is adjacent to the man numbered with 1). Then count M people from the man numbered with 1, and have the M-th person get out of the circle. This kind of operation continues, and every time the counting starts from the person who is right after the person going out in the last term.
Input A single line of input contains four integers N, M, K, J (1 <= M, N <= 10000000, 1 <= K <= 20000, 1 <= K <= N+1, 1 <= J <= N+1). N, M and K have the same meaning as described above, and J is the kingĄ¯s number. Output The output contains two integers in one line separated by a space. The first integer represents the number of person who will gain the money, and the second integer represents in which term the king will go out. Sample Input
Sample Output
Source POJ Monthly,Loger |
[Submit] [Go Back] [Status] [Discuss]
All Copyright Reserved 2003
Any problem, Please Contact Administrator