#P1826. 猴子选大王数据再加强版
猴子选大王数据再加强版
Description
There are monkeys standing in a circle, numbered clockwise as . Starting from the first monkey, repeatedly perform the following: count exactly monkeys clockwise, make that monkey leave the circle, then start counting again from the next monkey. Continue this process until only one monkey remains. The last remaining monkey is the winner of the game.
Now, for , determine which monkey ID becomes the winner the most times, and output its ID. If multiple monkeys tie for the most wins, output their IDs in increasing order.
Input Format
A single line containing three numbers , as described.
Output Format
Output two lines.
The first line outputs the maximum number of wins among all monkeys.
The second line outputs several numbers, which are the monkeys' IDs.
1 10 3
4
1
Hint
Sample Explanation
| Winner ID | ||||||||||
Therefore, monkey has the most wins, with wins.
Constraints
For of the testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号