hide handkerchief

来源:互联网 发布:淘宝网雪纺胖妹妹长袖 编辑:程序博客网 时间:2024/05/16 01:39

hide handkerchief

Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 585    Accepted Submission(s): 262

Problem Description
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 A. 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 A . Then he will search the box B ,then he will search the box A.
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 should tell me "YES", else tell me "POOR Haha".
 

 

Input
There will be several test cases; each case input contains two integers N and M, which satisfy the relationship: 1<=M<=100000000 and 3<=N<=100000000. When N=-1 and M=-1 means the end of input case, and you should not process the data.
 

 

Output
For each input case, you should only the result that Haha can find the handkerchief or not.
 

 

Sample Input
3 2-1 -1
 

 

Sample Output
YES
 

 

Source
计算机学院ACM大学生程序设计竞赛(2007’6)
http://acm.hdu.edu.cn/showproblem.php?pid=2104

这题思想很简单,MN辗转求余,如果结果为0,则不能遍历每个点,如果结果为1,则可以遍历

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 孕中期体重猛长怎么办 4个半月胎位不正怎么办 41周不产生宫缩怎么办 生完孩子胎盘没有脱落怎么办 39周还是臀位怎么办 怀孕7个月胎位不正怎么办 怀孕六个多月胎位不正怎么办 怀孕七个月了胎位不正怎么办 怀孕七个月胎位不正怎么办 怀孕肚子上有妊娠纹怎么办 怀孕九个月肚子长痱子怎么办 怀孕前体重偏胖怎么办 怀孕打胰岛素血糖控制不好怎么办 孕后期憋的难受怎么办 怀孕6个月不想生怎么办 孕六个月不想要怎么办 怀孕9个月喝酒了怎么办 怀孕8个月喝醉了怎么办 怀孕6个月胃酸烧心怎么办 怀孕7个月胃酸怎么办 怀孕5个月胃酸怎么办 怀孕2个月胃酸怎么办 怀孕六个月胃酸烧心怎么办 孕六个月反胃酸怎么办 怀孕三个月胃酸吐酸水怎么办 孕六个月胃难受怎么办 孕6个月胃酸厉害怎么办 孕妇6个月胃酸怎么办 孕早期胎盘早剥怎么办 孕妇晕车怎么办最有效方法 怀孕了受凉胃疼怎么办 怀孕4个月胎位低怎么办 6个月胎位低怎么办 7个多月了胎位低怎么办 瑜伽按摩球破了怎么办 孕妇吐完胸口疼怎么办 孕25周胸口堵怎么办呢 孕期没做过产检怎么办 宝宝的泪囊堵塞怎么办 瑜伽球塞子丢了怎么办 瑜伽球塞子没了怎么办