두~~부 두부 두부
Time limit1sMemory limit1024 MB
Given N players in a circle, caller M, and called mo count K, output the number of the player whose mo count is K, who takes the next turn.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Junseo, who has just finished his exams, is drinking with his friends.
두~~부 두부 두부 으쌰 으쌰 으쌰 두~~부 두부 두부 으쌰 으쌰 으쌰
A lively song starts playing from somewhere, and it makes everyone's shoulders move. The friends get up, dance, and begin to sing along.
Including Junseo, people are playing the game while singing. Since they can no longer say long names, they tell each other apart by numbers ~. The friends sit in a circle, with the numbers increasing counterclockwise.
The person numbered , who was singing, calls out doo-bu.
Junseo, who sees a drinking game he does not know, quietly asks his neighbor Junwoo hyung about the rules.
- The person whose turn it is calls out one integer .
- The caller becomes the reference point with mo.
- The neighbor counterclockwise gets 1 more mo, and the neighbor clockwise gets 1 less.
- The person whose mo count is takes the next turn, and the game repeats.
- Anyone who calls out when it is not their turn, or does not call out on their own turn, must drink.
Junseo has heard the explanation, but he is too drunk to follow it and cannot tell who goes next. Tell him the number of the next person so he does not get caught by this drinking game!
Input
The first line contains three integers: (), the number of people playing, (), the number of the person whose turn it is, and (), the mo count called.
Output
Print the number of the person whose turn is next.
Hint
The figure below shows how the players in the doo-bu game work out their mo counts when and .
