Statistics

Problem Statement for "PowerOfThree"

Problem Statement

Fox Ciel has a robot. The robot is located on an infinite plane. At the beginning, the robot starts at the coordinates (0, 0). The robot can then make several steps. The steps are numbered starting from 0.

In each step, Ciel must choose one of four directions for the robot: left (x coordinate decreases), right (x coordinate increases), up (y coordinate increases), or down (y coordinate decreases). In step k, the robot will move 3^k units in the chosen direction. It is not allowed to skip a step.

You are given ints x and y. Return "Possible" (quotes for clarity) if it is possible that the robot reaches the point (x,y) after some (possibly zero) steps. Otherwise, return "Impossible".

Definition

Class:
PowerOfThree
Method:
ableToGet
Parameters:
int, int
Returns:
String
Method signature:
String ableToGet(int x, int y)
(be sure your method is public)

Constraints

  • x will be between -1,000,000,000 and 1,000,000,000, inclusive.
  • y will be between -1,000,000,000 and 1,000,000,000, inclusive.

Examples

  1. 1

    3

    Returns: "Possible"

    In step 0 Ciel will send the robot right to (1,0). In step 1 she will send it up to (1,3).

  2. 0

    2

    Returns: "Possible"

    The robot will move from (0,0) down to (0,-1) and then up to (0,2).

  3. 1

    9

    Returns: "Impossible"

    Note that it is not allowed to move the robot right in step 0, skip step 1, and then move the robot up in step 2.

  4. 3

    0

    Returns: "Impossible"

  5. 1

    1

    Returns: "Impossible"

  6. -6890

    18252

    Returns: "Possible"

  7. 1000000000

    -1000000000

    Returns: "Impossible"

  8. 0

    0

    Returns: "Possible"

  9. -33520

    30281

    Returns: "Impossible"

  10. 760

    -427

    Returns: "Impossible"

  11. -2587

    2543

    Returns: "Impossible"

  12. 8183

    31

    Returns: "Impossible"

  13. 21466

    -6546

    Returns: "Possible"

  14. 1

    0

    Returns: "Possible"

  15. 4939786

    -2071240

    Returns: "Impossible"

  16. 730

    11244

    Returns: "Possible"

  17. -390

    -674

    Returns: "Impossible"

  18. 45006978

    16259019

    Returns: "Impossible"

  19. -834

    -2423

    Returns: "Impossible"

  20. -4

    0

    Returns: "Possible"

  21. -49655226

    -12849144

    Returns: "Impossible"

  22. -6517694

    -2103845

    Returns: "Impossible"

  23. 82

    39

    Returns: "Possible"

  24. 9

    -31

    Returns: "Possible"

  25. -894

    6

    Returns: "Impossible"

  26. -1

    -933

    Returns: "Impossible"

  27. -834

    240

    Returns: "Impossible"

  28. -1406

    -8038

    Returns: "Impossible"

  29. 0

    -1

    Returns: "Possible"

  30. 4832

    87

    Returns: "Possible"

  31. 4510

    38643

    Returns: "Possible"

  32. 4251560

    -1328643

    Returns: "Possible"

  33. -62947067

    4335075

    Returns: "Impossible"

  34. 12876795

    469243533

    Returns: "Impossible"

  35. 164789

    -732549

    Returns: "Impossible"

  36. -570240

    1412834

    Returns: "Possible"

  37. -252

    112

    Returns: "Possible"

  38. 51319

    19761

    Returns: "Impossible"

  39. -52826416

    -126980578

    Returns: "Impossible"

  40. -3995580

    -1602089

    Returns: "Impossible"

  41. -40

    -81

    Returns: "Possible"

  42. 1191

    -4911

    Returns: "Impossible"

  43. 125349

    -22193

    Returns: "Possible"

  44. -583503

    1439320

    Returns: "Impossible"

  45. -101353

    -1356932

    Returns: "Impossible"

  46. 13

    108

    Returns: "Possible"

  47. 68

    142

    Returns: "Impossible"

  48. -26620323

    -124180206

    Returns: "Impossible"

  49. -31184

    -354255

    Returns: "Possible"

  50. 26890

    -2493

    Returns: "Impossible"

  51. 5

    3

    Returns: "Impossible"

  52. -14965663

    16183026

    Returns: "Impossible"

  53. -4

    99

    Returns: "Possible"

  54. -3

    -1

    Returns: "Possible"

  55. -56095

    -44258

    Returns: "Impossible"

  56. 18179884

    -43068358

    Returns: "Impossible"

  57. 13

    0

    Returns: "Possible"

  58. 37

    -208

    Returns: "Impossible"

  59. -4428786

    -1630042

    Returns: "Impossible"

  60. 3

    1

    Returns: "Possible"

  61. -96146127

    -1769193

    Returns: "Impossible"

  62. -1

    0

    Returns: "Possible"

  63. -20328064

    39278281

    Returns: "Impossible"

  64. -80875

    -7044

    Returns: "Possible"

  65. 6453849

    -201246700

    Returns: "Impossible"

  66. -4868873

    -887682

    Returns: "Possible"

  67. 17985

    5957452

    Returns: "Possible"

  68. 0

    0

    Returns: "Possible"

  69. -2713314

    190426

    Returns: "Impossible"

  70. 600

    2555

    Returns: "Impossible"

  71. 423

    201

    Returns: "Impossible"

  72. 26

    93

    Returns: "Possible"

  73. -1370

    2934

    Returns: "Impossible"

  74. -7417542

    86217941

    Returns: "Impossible"

  75. -714

    -352

    Returns: "Impossible"

  76. 1

    0

    Returns: "Possible"

  77. 8157

    -8

    Returns: "Possible"

  78. -345246858

    -109951550

    Returns: "Impossible"

  79. 27

    -68

    Returns: "Possible"

  80. 894539

    419814

    Returns: "Impossible"

  81. -171387

    -489722

    Returns: "Impossible"

  82. -9081

    -38612

    Returns: "Possible"

  83. -228

    -773

    Returns: "Impossible"

  84. -57134074

    -131729989

    Returns: "Impossible"

  85. -109745

    7952

    Returns: "Impossible"

  86. 0

    1

    Returns: "Possible"

  87. 192788

    589629

    Returns: "Impossible"

  88. -49826925

    -14348830

    Returns: "Possible"

  89. -21465

    -6595

    Returns: "Possible"

  90. -288049

    -1423705

    Returns: "Impossible"

  91. 43268500

    -7440135

    Returns: "Possible"

  92. -9

    -2

    Returns: "Possible"

  93. 73

    70932

    Returns: "Possible"

  94. 643132

    551654013

    Returns: "Possible"

  95. -3372

    -1271

    Returns: "Impossible"

  96. 2090

    -3233

    Returns: "Impossible"

  97. 0

    0

    Returns: "Possible"

  98. 27102038

    4461291

    Returns: "Possible"

  99. 2617

    -668

    Returns: "Impossible"

  100. -37

    84

    Returns: "Possible"

  101. -598225

    -1401267

    Returns: "Impossible"

  102. 700

    -557

    Returns: "Impossible"

  103. -45814759

    50118349

    Returns: "Impossible"

  104. 0

    1

    Returns: "Possible"

  105. 243714

    -20145890

    Returns: "Impossible"

  106. -26060921

    4152856

    Returns: "Impossible"

  107. 387420285

    4

    Returns: "Impossible"

  108. 176795652

    375112369

    Returns: "Possible"

  109. -774840978

    193710244

    Returns: "Possible"

  110. 581130734

    0

    Returns: "Possible"

  111. 2

    2

    Returns: "Impossible"

  112. -581130726

    1

    Returns: "Possible"

  113. 774840978

    -193710244

    Returns: "Possible"

  114. 0

    4

    Returns: "Possible"

  115. 186909767

    781285137

    Returns: "Possible"

  116. -581130734

    0

    Returns: "Possible"

  117. 5

    8

    Returns: "Impossible"

  118. 6

    7

    Returns: "Impossible"

  119. 193710244

    0

    Returns: "Possible"

  120. 797161

    0

    Returns: "Possible"

  121. 4

    -5

    Returns: "Impossible"

  122. 3

    -3

    Returns: "Impossible"

  123. -581130733

    0

    Returns: "Possible"

  124. 21523360

    0

    Returns: "Possible"

  125. -6890

    -18252

    Returns: "Possible"

  126. 1041

    9467

    Returns: "Impossible"

  127. 4

    7

    Returns: "Impossible"

  128. 4

    0

    Returns: "Possible"

  129. 9565938

    -3456554

    Returns: "Impossible"

  130. -1

    -3

    Returns: "Possible"

  131. 20076739

    301299120

    Returns: "Possible"

  132. 0

    -581130733

    Returns: "Possible"

  133. 0

    871696100

    Returns: "Possible"

  134. 8

    3

    Returns: "Possible"

  135. 2

    1

    Returns: "Impossible"

  136. 19684

    19686

    Returns: "Impossible"

  137. 6

    28

    Returns: "Possible"

  138. 535869684

    45261049

    Returns: "Possible"

  139. -4

    -9

    Returns: "Possible"

  140. 4902

    1153

    Returns: "Impossible"

  141. 3

    10

    Returns: "Possible"

  142. -797162

    0

    Returns: "Possible"

  143. 26

    6

    Returns: "Possible"

  144. 1000000000

    162261467

    Returns: "Impossible"

  145. 25

    18

    Returns: "Impossible"

  146. -21523361

    0

    Returns: "Possible"

  147. 238

    621

    Returns: "Possible"

  148. 4

    -3

    Returns: "Impossible"

  149. 9

    0

    Returns: "Impossible"

  150. 1

    93

    Returns: "Impossible"

  151. 387420489

    0

    Returns: "Impossible"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: