403528: GYM101191 A Game with chocolates

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Game with chocolatestime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Peter and Vasya have birthdays at the same date. Perhaps, that is a reason why they were given the same boxes of chocolates. But it was too boring for friends just to eat these chocolates, so they decided to make a prize in the game from these chocolates.

The player for a one move is allowed to take from any box a number of chocolates such that there were less chocolates left than in the other box. Let after move in boxes left N and M chocolates (N > M). Then the number N - M must be non-negative i-th power of P (in other words N - M = Pi, i ≥ 0). And the integer part of a division N by the difference N - M should not be a multiple of P, or [N / (N - M)] mod P ≠ 0.

Parents love their children, so the number of chocolates in each of the boxes can be quite big and game could be delayed. That's why the guys would like to know if the initial configuration of chocolates (X chocolates in the Peter's box and Y in the Vasek's box) is advantageous for the player who will make the first move. Situation is advantageous, if it is possible to bring the game to at least one losing position, and the situation is losing, if it is impossible to bring the game into another losing position.

The player is a loser if he can't make the next move.

Find out the success of the initial situation in the game.

Input

There are three positive integers in the line: P (the difference should be a power of this number), X, Y (numbers of chocolates in the Peter's and Vasek's boxes respectively) (2 ≤ P, X, Y ≤ 1018).

Output

In the first line you should write a message «NO», if the position is losing and «YES», if it is advantageous.

In the case of advantageous position you should write any of the following playing positions such that is losing.

ExamplesInput
2 3 5
Output
NO
Input
3 3 3
Output
YES
3 0

加入题单

算法标签: