Marks :15
: 6 | : 0
You are standing at coordinates $$$(1,1)$$$ of an infinite 2D plane. From cell $$$(x,y)$$$, you can move to either $$$(2x,y)$$$ or $$$(x,2y)$$$ or $$$(x-y,y)$$$ or $$$(x,y-x)$$$.
Your task is to find out if you can reach cell $$$(n,m)$$$ through a series of moves.
The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^5)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.
The first and only line of each testcase contains two integers $$$n$$$ and $$$m$$$ $$$(1 \le n,m \le 10^{18})$$$ — the coordinates of the destination as specified in the problem statement.
For each testcase, print "Yes" if you can reach the cell $$$(n,m)$$$ through a series of moves and "No" otherwise.
41 23 44 710 10
Yes Yes Yes No
In sample test case 1, we can simply use the second move to reach $$$(1,2)$$$ from $$$(1,1)$$$.
In sample test case 2, one of the ways to reach $$$(3,4)$$$ is $$$(1,1)\rightarrow (2,1)\rightarrow (4,1)\rightarrow (3,1)\rightarrow (3,2)\rightarrow (3,4)$$$.
In sample test case 3, one of the ways to reach $$$(4,7)$$$ is $$$(1,1)\rightarrow (1,2)\rightarrow (1,4)\rightarrow (1,8)\rightarrow (1,7)\rightarrow (2,7)\rightarrow (4,7)$$$.
In sample test case 4, It can be proved that you cannot reach $$$(10,10)$$$ through any series of moves.
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.