#P1965. [NOIP 2013 提高组] 转圈游戏
[NOIP 2013 提高组] 转圈游戏
Description
friends (numbered from to ) sit in a circle to play a game. The positions are numbered clockwise from to . Initially, friend is at position , friend is at position , and so on. The rules are as follows: in each round, the friend at position moves clockwise to position , the friend at position moves to position , and so on; the friend at position moves to position , the friend at position moves to position , ... , and the friend at position moves clockwise to position .
Now, after a total of rounds, determine which position friend ends up at.
Input Format
One line containing four integers , with a single space separating each pair of integers.
Output Format
One integer, the position index where friend is located after rounds.
10 3 4 5
5
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号