#P2818. Finding the Correct Script Box
Finding the Correct Script Box
Finding the Correct Script Box
An angel is tasked with finding her speech manuscript from among n boxes arranged in a circle with labels from 1 to n in a clockwise direction. Although all angels initially stand by the nth box, each angel holds a number m which denotes that her manuscript is in the box that is the m-th in order starting from box 1 (in clockwise order).
For example, if there are 7 boxes and the angel's number is 9, then her manuscript is in box 2 because
Help the angel determine the correct box number where her manuscript is located. Use the formula below:
inputFormat
The input consists of two space-separated integers: n
(the number of boxes) and m
(the number in the angel's hand).
outputFormat
Output the box number where the angel's manuscript is located.
sample
7 9
2