Doubt in UVa problem 113 - Power of Cryptography

I saw this problem - 113- Power of cryptography on UVa OJ : [Online Judge][1]

This does seem like a number theory or binary search question, but this AC solution is found on many blogs online - [competitive-programming/uva 113 - Power of Cryptography.cpp at master · magdyhasan/competitive-programming · GitHub][2]

This solution is pretty naive but still manages to pass. From what I knew, double in c++ supports only 15 significant digits. That means this solution should not have passed (p, of which nth root is to be found, has 200ish digits.)

Are test-cases of this question weak or this solution should have actually passed?

Also, share approaches apart from binary search to solve this question.
[1]: Online Judge
[2]: competitive-programming/uva 113 - Power of Cryptography.cpp at master · magdyhasan/competitive-programming · GitHub

1 Like

I think the test cases are weak!

1 Like

15 significant digits is much more than 9 significant digits required in answer.