favorite We need a little bit of your help to keep things running, click on this banner to learn more

DSLCS 2011 Number Theory. Favorites

Gergs cake

Gerg is having a party, and he has invited his friends. p of them have arrived already, but a are running late. To occupy his guests, he tried playing some team games with them, but he found that it was impossible to divide the p guests into any number of equal-sized groups of more than one person.

Luckily, he has a backup plan - a cake that he would like to share between his friends. The cake is in the shape of a square, and Gerg insists on cutting it up into equal-sized square pieces. He wants to reserve one slice for each of the a missing friends, and the rest of the slices have to be divided evenly between the p remaining guests. He does not want any cake himself. Can he do it?


The input will consist of several test cases. Each test case will be given as a non-negative integer a and a positive integer p as specified above, on a line. Both a and p will fit into a 32-bit signed integer. The last line will contain "-1 -1" and should not be processed.


For each test case, output "Yes" if the cake can be fairly divided and "No" otherwise.

Time limit 1 second
Memory limit 64 MiB
Input example #1
1 3
1024 17
2 101
0 1
-1 -1
Output example #1