| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10538 | Mid1 Josephus Composite |
|
| 10543 | Mid1 Queue |
|
Description
The Josephs problem is notoriously known. For those who are not familiar with the problem, among n people numbered 1, 2, . . . , n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give the message about the incident.
Then print 6 as answer.
Input
There will be more than one line, each line with one integer n. n is the number of people. Input terminated by EOF.
Output
The output will consist in separate lines containing the position of the person which life will be saved.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Consider a queue of groups. Each group has a unique ID denoted by a string of uppercase alphabets. The length of an ID is less than or equal to 6 characters.
Input
The input contains several lines. Each line presents the group ID and the name of a new comer. The group ID and the name are separated by a space.
The string in the last line is always "END" indicating the end of the input.
Output
The output contains one line. The first string is the ID of the last group in the queue. After that you need to print the name of members in the last group, one by one according to their coming order.