#P1826. 猴子选大王数据再加强版

猴子选大王数据再加强版

Description

There are nn monkeys standing in a circle, numbered clockwise as 1,2,3,,n1, 2, 3, \cdots, n. Starting from the first monkey, repeatedly perform the following: count exactly mm 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 n=a,a+1,,bn = a, a + 1, \cdots, b, 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 a,b,ma, b, m, 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

n=n= 11 22 33 44 55 66 77 88 99 1010
Winner ID 11 22 11 44 11 44 77 11 44

Therefore, monkey 11 has the most wins, with 44 wins.

Constraints

For 100%100\% of the testdata, it is guaranteed that 1ab1061 \leq a \leq b \leq 10^6, m3000m \leq 3000.

Translated by ChatGPT 5