HDU Wolf and rabbit

Source: Internet
Author: User
Wolf and rabbit
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 335 accepted submission (s): 214
Problem descriptionthere is a hill with N holes around. The holes are signed from 0 to n-1.

A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. the first hole he get into is the one signed with 0. then he will get into the hole every m holes. for example, m = 2 and n = 6, the wolf will get into the holes which are signed. if the rabbit hides in the hole which signed 1, 3 or 5, she will keep ve. so we call these holes the safe holes.

 
Inputthe input starts with a positive integer p which indicates the number of test cases. then on the following P lines, each line consists 2 positive integer m and n (0 <m, n <2147483648 ).
Output for each input m n, if safe holes exist, you shoshould output "yes", else output "no" in a single line.
Sample Input
21 22 2
 
sample output
 Noyes 

# include
# include
using namespace STD;
int main ()
{< br> int T, m, n;
CIN> T;
while (t --)
{< br> CIN> m> N;
while (n> M? (N = n % m) :( M = m % N);
If (n + M = 1) printf ("NO \ n ");
else printf ("Yes \ n");
}< br> return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.