The Children's day has passed for some days. Has you remembered something happened at your childhood? I remembered I often played a game called hide handkerchief with my friends.
Now I introduce the game to you. suppose there are n people played the game, who sit on the ground forming a circle, everyone owns a box behind them. also there is a beautiful handkerchief hid in a box which is one of the boxes.
Then Haha (a friend of mine) is called to find the handkerchief. but he has a strange habit. each time he will search the next box which is separated by M-1 boxes from the current box. for example, there are three boxes named A, B, C, and now Haha is at place of. now he decide the m if equal to 2, so he will search a first, then he will search the C box, for C is separated by 2-1 = 1 box B from the current Box. then he will search the Box B, then he will search the box.
So after three times he establishes that he can find the beautiful handkerchief. now I will give you n and M, can you tell me that Haha is able to find the handkerchief or not. if he can, you shoshould tell me "yes", else tell me "poor haha ".
If m and n are not mutually compatible, some students will never be reached.
//
// Main. c
// Hdu1.2.3
//
// Created by Wuxi on 14-10-27.
// Copyright (c) 2014 Wuxi. All rights reserved.
//
# Include <stdio. h>
Int gcd (int x, int y)
{
If (X % Y = 0) return y;
Return gcd (Y, X % Y );
}
Int main (){
Int m, n, Q;
While (1 ){
Scanf ("% d", & M, & N );
If (M =-1 & n =-1) break;
If (M> = N)
Q = gcd (m, n );
Else q = gcd (n, m );
If (q = 1) printf ("Yes \ n ");
Else printf ("poor Haha \ n ");
}
Return 0;
}
ACM step 1.2.3 hide handkerchief