Goldman SachsOA #16
Find the Damaged Toy
Estimated EasyJudge-ready
Topics (AI-labelled)Bits & MathSimulation
N children numbered 1..N sit in a circle. The first toy goes to child D, and the remaining toys are handed out one at a time in increasing order of number, wrapping around to 1. Find who receives the T-th (last) toy.
Input
A single line containing N T D. This site adds 1≤N,T≤10^9 and 1≤D≤N.
Output
Output the 1-based number of the child who receives the last toy.
Example 1
Input:
5 2 1
Output:
2
Example 2
Input:
5 1 4
Output:
4
Example 3
Input:
3 7 2
Output:
2
Editorial
Loading solution…