Nice problem!! Although I must say that I undrestimated the problem at first sight

. A very well-designed and sophisticated judge data, great job Shahriar Manzoor. I got AC with long long int, I think double/long double would also work fine as many others claimed to get AC with these, but I would certainly recommend long long int.
Don't use int because my program got the verdict Wrong Answer with int. Also make sure you are printing a '.' after Impossible
Possible reasons why your program might get a Wrong Answer:
1. Your algorithm is incorrect.
2. Your algorithm can't handle cases like 0 0, 1 0, 0 8, -1 0, -5 -7, etc
3. I got wrong answer twice because of this silly mistake. The problem clearly says if there are multiple solutions of x and y, then print the set of solutions with the lowest value of x(I actually ignored this statement as Im very impatient

). Now consider the case 2 0. What should be the output here? My AC code, gives -1 -1. But notice that 1 1 is also another possible solution, but here as -1 is < 1 we have to print the former set of values.
Now finally some I/O which I generated after solving this problem. Hope I can help you

Thanks.
Code: Select all
40
8 12
12 8
4 6
0 0
0 1
0 2
0 8
0 64
0 32
0 31
0 20
2 0
1024 0
65536 0
729 0
5 3
-4 -6
-2 -12
8 -12
0 -1
-16 0
16 24
24 16
512 0
0 512
26250 -3125
20902684 1580181
1006826600 48139500
7950 4268
12343210 3702963
-1381662 11479312
1250075001 -25000
1539187879 149758950
2112313210 37032963
2185144815 -35798642
2185144814 -35798642
1006826601 48139500
1006826600 48139501
1006826600 48139500
2147294608 33311922
Code: Select all
Case 1:
2 -4
Case 2:
4 2
Case 3:
3 1
Case 4:
0 0
Case 5:
1 0
Case 6:
1 -1
Case 7:
2 -2
Case 8:
8 0
Case 9:
4 -4
Case 10:
Impossible.
Case 11:
Impossible.
Case 12:
-1 -1
Case 13:
0 -32
Case 14:
0 -256
Case 15:
0 -27
Case 16:
Impossible.
Case 17:
Impossible.
Case 18:
Impossible.
Case 19:
Impossible.
Case 20:
Impossible.
Case 21:
Impossible.
Case 22:
6 2
Case 23:
2 -6
Case 24:
-16 -16
Case 25:
16 -16
Case 26:
-25 -150
Case 27:
3567 3124
Case 28:
23950 21940
Case 29:
97 53
Case 30:
3333 2222
Case 31:
3133 -531
Case 32:
-25000 -25001
Case 33:
31350 26573
Case 34:
33333 32222
Case 35:
-32222 -33333
Case 36:
Impossible.
Case 37:
Impossible.
Case 38:
Impossible.
Case 39:
23950 21940
Case 40:
33513 32519
Lol if you still get Wrong Answer after matching all of the above I/O and you have considered that you need to print the set with lowest value of x if multiple solutions exist, then no one can help you

.