Hide

Problem G
Circular Walk

You recently moved to a new neighbourhood, your house lays at point $b$ on a circular path containing $n$ points. The neighbourhood has an odd rule, you can only go from a location at point $i$ to a location at point $j$ if the number of steps from $i$ to $j$ going clockwise around the circle is a multiple of some given integer $k$. There’s a new installment in the neighbourhood at point ‘0’. Given the neighbourhood’s peculiar rule are you able to visit the installment?

\includegraphics[width=0.6\textwidth ]{circularwalk.pdf}
Figure 1: Illustration of the sample cases. The dashed point is the starting point. The points shaded grey are the ones reachable from the starting point.

Input

The first and only line of input contains three space seperated integers, the number of points in the neighbourhood $2 \leq n \leq 1\, 000\, 000\, 000$, the point your house is located at $1 \leq b < n$, and the value $1 \leq k < n$ from the problem description above.

Output

Output a single line containing ‘YES’ if you can visit point ‘0‘, otherwise output ‘NO’.

Sample Input 1 Sample Output 1
4 2 2
YES
Sample Input 2 Sample Output 2
4 3 2
NO
Sample Input 3 Sample Output 3
12 7 10
NO

Please log in to submit a solution to this problem

Log in