Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
Statistical Charts
Submit Problem
Online Status
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
National Day Celebration
Time Limit: 2000MSMemory Limit: 65536K
Total Submissions: 428Accepted: 185


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.
The king declares that the person going out in the K-th term will gain a lot of money. The king is eager to know who will be the lucky person and when he will go out. He asks you to make a program to tell him.


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.


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

10 3 5 8

Sample Output

5 9


[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator