#C9916. Empty Seat Position on Circular Carousel
Empty Seat Position on Circular Carousel
Empty Seat Position on Circular Carousel
There are n seats arranged in a circle numbered from 1 to n. Initially, the m-th seat is empty. At each step, the empty seat moves one position in a clockwise direction. After performing k steps, your task is to determine the new position of the empty seat.
This movement can be described mathematically using modular arithmetic as follows:
$$((m-1+k) \mod n) + 1$$
Use this formula to compute the final position.
inputFormat
The input consists of a single line containing three space-separated integers:
- n: the total number of seats (1 ≤ n ≤ 106),
- m: the initial position of the empty seat (1 ≤ m ≤ n),
- k: the number of steps (0 ≤ k ≤ 1012).
outputFormat
Output a single integer representing the position of the empty seat after k steps.
## sample6 2 3
5