Infinite GP in Infinite GP

All submissions for this problem are available.
Consider an infinite geometric sequence S={1, ^{1}⁄_{2}, ^{1}⁄_{4}, ^{1}⁄_{8} … }.
For given fraction ^{p}⁄_{q}, check whether one can select an infinite geometric sequence R, such that R ⊆ S and Summation of all elements in R is ^{p}/_{q}
.
Input Format
First line contains an integer T, representing the number of test cases. The next T lines,each contain two space separated integers, p and q.
Output Format
The output should contain T lines, one for each test case. If there exists such a sequence satisfying the given constraint, print "YES" (without quotes), else print "NO".
Constraints
 T ≤ 50000
 1 ≤ p,q ≤ 1e9
Sample Input :
2
3 1
1 3
Sample Output :
NO
YES
Explanation :
For 1st test case, there cannot exist any series with sum as 3, since maximum sum possible is 2.
For 2nd test case, the series beginning with ^{1}⁄_{4} and geometric factor as ^{1}⁄_{4}, has sum ^{1}⁄_{3}
Author:  iopc_admin 
Tags  iopc_admin 
Date Added:  2022014 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP 4.3.2, CPP 4.9.2, GO, JAVA 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions