How to solve this grid problem ?

Revision en1, by aopo, 2022-10-03 12:54:38

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

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English aopo 2022-10-03 12:54:38 359 Initial revision (published)