Problem Description
There 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 0,2,4,0. If the rabbit hides in the hole which signed 1,3 or 5, she will survive. So we call these holes the safe holes.

The 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).
For each input m n, if safe holes exist, you should output "YES", else output "NO" in a single line.
Sample Input
1 2
2 2
Sample Output

The problem is equivalent to finding whether two numbers are coprime . We should study the application of mathematics .
int main()
int m,n,i,k,flag,t;
return ;

hdu 1222 Wolf and Rabbit More articles about

  1. HDU 1222 Wolf and Rabbit(gcd)

    HDU 1222   Wolf and Rabbit   ( greatest common divisor ) Problem solving report Topic link : ...

  2. HDU 1222 Wolf and Rabbit( Euclid )

    Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  3. HDU 1222 Wolf and Rabbit( mathematics , Looking for a regular )

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  4. HDU 1222 - Wolf and Rabbit &amp; HDU 1108 - [ greatest common divisor &amp; Minimum common multiple ]

    Water problem , I just want to take this opportunity to remember gcd Templates for functions #include<cstdio> int gcd(int m,int n){return n?gcd(n,m%n):m;} int main() { ...

  5. HDU 1222 Wolf and Rabbit( Simple tuoou )

    link : Portal The question : The wolf catches the rabbit , Wolf from 0 Set out to look for the rabbit counter clockwise , The distance of each step is m , All the caves are numbered 0 - n-1 , Ask if there is a cave where rabbits can escape countless wolf searches . Ideas : Simply expand euromile ...

  6. 【HDOJ】1222 Wolf and Rabbit

    greatest common divisor , division algorithm . #include <stdio.h> long long gcd(long long a, long long b) { if (a<b) return gc ...

  7. Wolf and Rabbit Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others ...

  8. Wolf and Rabbit(gcd)

    Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. gcd( greatest common divisor )lcm( Minimum common multiple )E - Wolf and Rabbit

    1.gcd Recursive implementation int gcd(int i,int j){ if(j==0) return i; else return gcd(j,i%j);} 2.lcm int gcd(int i,int ...

Random recommendation

  1. utilize for Loop to find out 1000 The prime number within

    var n=0; for(var i=2;i<=1000;i++){  var zhishu=true;  for(var j=2;j<i;j++){    if(i%j==0){    ...

  2. LYDSY Simulation game day3 Sequence

    NOIP No test can last , Abandoned pit

  3. The front-end technology -PS Cutaway

    Page production part PS Cutaway <-- Under this label , Through page production . Page structure .javascript Programming .DOM Programming art . There are five parts of product front-end architecture to share summary notes , Summary notes will be shared one after another --> Web design at the technical level ...

  4. ListView The use of,

    stay ListView Set in Selector by null A null pointer will be reported ?mListView.setSelector(null);// Null pointer try this one :mListView.setSelector(new Col ...

  5. Java DecimalFormat Data format example

    public static void main (String args[]) { DecimalFormat dFormat = new DecimalFormat(".##") ...

  6. static Advanced usage of objects

    1. In the function static The object is local Of , Other things like global objects , Generic static The objects are all right and wrong local Of , Will be created in advance in the program initialization 2. Not local The creation of objects for cannot be prioritized , But it's guaranteed to be in main Function before ...

  7. [LeetCode] Answer key (python):072-Edit Distance

    Title source : Problem analysis : word1 At least how many steps can be taken to become word2.word1 Only one operation can be carried out .a) Insert a ...

  8. [ Roof placement ] bootstrap Custom style -bootstrap Implementation of side navigation bar

    Preface bootstrap The built-in responsive navigation bar slides down , Sometimes it can't meet the personalized needs , You need to do something like android drawerLayout Sideslip menu , That's what I want to achieve bootstrap Custom sideslip menu ...

  9. 1-1 struts2 Basic configuration struts.xml Configuration file details

    See One . struts2 working principle ( Summary of netizens , It's the same all the time ) 1 Client initializes a point Servlet Containers ( for example Tomc ...

  10. ES3 It's variable promotion ( hoisting )

    JavaScript When the engine is precompiled , Will declare ( Function declaration . Variable declarations ) Automatically promote to the top of a function or global code . But assignment doesn't improve . Because variable declarations (and declar ...