Problem Statement
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
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
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).
0
2
Returns: "Possible"
The robot will move from (0,0) down to (0,-1) and then up to (0,2).
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.
3
0
Returns: "Impossible"
1
1
Returns: "Impossible"
-6890
18252
Returns: "Possible"
1000000000
-1000000000
Returns: "Impossible"
0
0
Returns: "Possible"
-33520
30281
Returns: "Impossible"
760
-427
Returns: "Impossible"
-2587
2543
Returns: "Impossible"
8183
31
Returns: "Impossible"
21466
-6546
Returns: "Possible"
1
0
Returns: "Possible"
4939786
-2071240
Returns: "Impossible"
730
11244
Returns: "Possible"
-390
-674
Returns: "Impossible"
45006978
16259019
Returns: "Impossible"
-834
-2423
Returns: "Impossible"
-4
0
Returns: "Possible"
-49655226
-12849144
Returns: "Impossible"
-6517694
-2103845
Returns: "Impossible"
82
39
Returns: "Possible"
9
-31
Returns: "Possible"
-894
6
Returns: "Impossible"
-1
-933
Returns: "Impossible"
-834
240
Returns: "Impossible"
-1406
-8038
Returns: "Impossible"
0
-1
Returns: "Possible"
4832
87
Returns: "Possible"
4510
38643
Returns: "Possible"
4251560
-1328643
Returns: "Possible"
-62947067
4335075
Returns: "Impossible"
12876795
469243533
Returns: "Impossible"
164789
-732549
Returns: "Impossible"
-570240
1412834
Returns: "Possible"
-252
112
Returns: "Possible"
51319
19761
Returns: "Impossible"
-52826416
-126980578
Returns: "Impossible"
-3995580
-1602089
Returns: "Impossible"
-40
-81
Returns: "Possible"
1191
-4911
Returns: "Impossible"
125349
-22193
Returns: "Possible"
-583503
1439320
Returns: "Impossible"
-101353
-1356932
Returns: "Impossible"
13
108
Returns: "Possible"
68
142
Returns: "Impossible"
-26620323
-124180206
Returns: "Impossible"
-31184
-354255
Returns: "Possible"
26890
-2493
Returns: "Impossible"
5
3
Returns: "Impossible"
-14965663
16183026
Returns: "Impossible"
-4
99
Returns: "Possible"
-3
-1
Returns: "Possible"
-56095
-44258
Returns: "Impossible"
18179884
-43068358
Returns: "Impossible"
13
0
Returns: "Possible"
37
-208
Returns: "Impossible"
-4428786
-1630042
Returns: "Impossible"
3
1
Returns: "Possible"
-96146127
-1769193
Returns: "Impossible"
-1
0
Returns: "Possible"
-20328064
39278281
Returns: "Impossible"
-80875
-7044
Returns: "Possible"
6453849
-201246700
Returns: "Impossible"
-4868873
-887682
Returns: "Possible"
17985
5957452
Returns: "Possible"
0
0
Returns: "Possible"
-2713314
190426
Returns: "Impossible"
600
2555
Returns: "Impossible"
423
201
Returns: "Impossible"
26
93
Returns: "Possible"
-1370
2934
Returns: "Impossible"
-7417542
86217941
Returns: "Impossible"
-714
-352
Returns: "Impossible"
1
0
Returns: "Possible"
8157
-8
Returns: "Possible"
-345246858
-109951550
Returns: "Impossible"
27
-68
Returns: "Possible"
894539
419814
Returns: "Impossible"
-171387
-489722
Returns: "Impossible"
-9081
-38612
Returns: "Possible"
-228
-773
Returns: "Impossible"
-57134074
-131729989
Returns: "Impossible"
-109745
7952
Returns: "Impossible"
0
1
Returns: "Possible"
192788
589629
Returns: "Impossible"
-49826925
-14348830
Returns: "Possible"
-21465
-6595
Returns: "Possible"
-288049
-1423705
Returns: "Impossible"
43268500
-7440135
Returns: "Possible"
-9
-2
Returns: "Possible"
73
70932
Returns: "Possible"
643132
551654013
Returns: "Possible"
-3372
-1271
Returns: "Impossible"
2090
-3233
Returns: "Impossible"
0
0
Returns: "Possible"
27102038
4461291
Returns: "Possible"
2617
-668
Returns: "Impossible"
-37
84
Returns: "Possible"
-598225
-1401267
Returns: "Impossible"
700
-557
Returns: "Impossible"
-45814759
50118349
Returns: "Impossible"
0
1
Returns: "Possible"
243714
-20145890
Returns: "Impossible"
-26060921
4152856
Returns: "Impossible"
387420285
4
Returns: "Impossible"
176795652
375112369
Returns: "Possible"
-774840978
193710244
Returns: "Possible"
581130734
0
Returns: "Possible"
2
2
Returns: "Impossible"
-581130726
1
Returns: "Possible"
774840978
-193710244
Returns: "Possible"
0
4
Returns: "Possible"
186909767
781285137
Returns: "Possible"
-581130734
0
Returns: "Possible"
5
8
Returns: "Impossible"
6
7
Returns: "Impossible"
193710244
0
Returns: "Possible"
797161
0
Returns: "Possible"
4
-5
Returns: "Impossible"
3
-3
Returns: "Impossible"
-581130733
0
Returns: "Possible"
21523360
0
Returns: "Possible"
-6890
-18252
Returns: "Possible"
1041
9467
Returns: "Impossible"
4
7
Returns: "Impossible"
4
0
Returns: "Possible"
9565938
-3456554
Returns: "Impossible"
-1
-3
Returns: "Possible"
20076739
301299120
Returns: "Possible"
0
-581130733
Returns: "Possible"
0
871696100
Returns: "Possible"
8
3
Returns: "Possible"
2
1
Returns: "Impossible"
19684
19686
Returns: "Impossible"
6
28
Returns: "Possible"
535869684
45261049
Returns: "Possible"
-4
-9
Returns: "Possible"
4902
1153
Returns: "Impossible"
3
10
Returns: "Possible"
-797162
0
Returns: "Possible"
26
6
Returns: "Possible"
1000000000
162261467
Returns: "Impossible"
25
18
Returns: "Impossible"
-21523361
0
Returns: "Possible"
238
621
Returns: "Possible"
4
-3
Returns: "Impossible"
9
0
Returns: "Impossible"
1
93
Returns: "Impossible"
387420489
0
Returns: "Impossible"