#C3211. Final Position of a Ball in a Circle

    ID: 46614 Type: Default 1000ms 256MiB

Final Position of a Ball in a Circle

Final Position of a Ball in a Circle

You are given a game scenario where n children are sitting in a circle, numbered from 0 to n-1. A ball is initially with the child at position start_pos and is passed to the right k times. Each pass moves the ball by one seat. Your task is to determine the final position of the ball after k passes.

The answer can be found using modulo arithmetic. Specifically, if the ball starts at position start_pos and is passed k times, then the final position is given by:

\( \text{final_pos} = (\text{start_pos} + (k \bmod n)) \bmod n \)

Make sure to handle large values of k properly.

inputFormat

The input consists of a single line containing three integers separated by spaces:

  • n — the number of children in the circle.
  • start_pos — the initial position of the ball.
  • k — the number of passes.

outputFormat

Output a single integer which denotes the final position of the ball after k passes.

## sample
5 0 2
2