There is a grid of ($$$10^{18}$$$, $$$10^{18}$$$) blocks. The person standing on (i, j) block can move to (2i, j) or (i, 2j) or (i-j, j) or(i, j-i) inside the grid. If he starts from (1, 1) output "Yes" if he/ she could reach (m, n) block else output "No".
Ex: Input:
3
1 2
4 7
10 10
Output:
Yes
Yes
No
Similar problem here. Might be a good idea to look for a rather "mathematical" solution, we can't just exhaustively search all cells.
$$$O(\log \min(m,n))$$$
Seems the algorithm is simple:
But link to the problem will be helpful, yes.
I too have the same idea, just a different way to find, $$$gcd(n, m) | 2^{k}$$$, for some $$$k \in [0;59]$$$.
I think this should be gcd(n,m) = $$$2^{k}$$$ for some k lying in [0,59].
Sorry, but i don't have link to the problem. But, your approach seems correct to me...
And yeah, I got if gcd(x,y)!=1 and x and y are odd then it's never possible. Since, any tranformation of any kind like (x,y) --> (x+y,y) or (x,x+y) doesn't change the gcd(x,y) which is in this case > 1