Tap here to switch tabs
Problem
Submissions

Problem: Check if Point Is Reachable

Check if Point Is Reachable asks whether a target point can be reached from the point one, one on an infinite grid by moves that subtract one coordinate from the other or double one coordinate.

Statement

You are standing at point (1,1)(1, 1) on an infinite two dimensional grid. From any point (x,y)(x, y), you can move to one of the following coordinates:

  • (x,y−x)(x, y - x)

  • (x−y,y)(x - y, y)

  • (2⋅x,y)(2 \cdot x, y)

  • (x,2⋅y)(x, 2 \cdot y)

Given two integers targetX and targetY, return true if you can reach the point (targetX, targetY) starting from (1,1)(1, 1), or false otherwise.

Constraints:

  • 1≤1 \leq targetX, targetY ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check if Point Is Reachable

Check if Point Is Reachable asks whether a target point can be reached from the point one, one on an infinite grid by moves that subtract one coordinate from the other or double one coordinate.

Statement

You are standing at point (1,1)(1, 1) on an infinite two dimensional grid. From any point (x,y)(x, y), you can move to one of the following coordinates:

  • (x,y−x)(x, y - x)

  • (x−y,y)(x - y, y)

  • (2⋅x,y)(2 \cdot x, y)

  • (x,2⋅y)(x, 2 \cdot y)

Given two integers targetX and targetY, return true if you can reach the point (targetX, targetY) starting from (1,1)(1, 1), or false otherwise.

Constraints:

  • 1≤1 \leq targetX, targetY ≤109\leq 10^9