Problem hidden on 2014-03-02 19:51:57 by Francky
IOPC_14O - Infinite GP in Infinite GP
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
Added by: | devu |
Date: | 2014-03-02 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Setter: Rachit Nimavat | Tester : Devendra Agarwal | Writter : Vijay Keswani |