Doubt in UVa problem 113 - Power of Cryptography

I saw this problem - 113- Power of cryptography on UVa OJ : [https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=49][1]

This does seem like a number theory or binary search question, but this AC solution is found on many blogs online - [https://github.com/magdy-hasan/competitive-programming/blob/master/uva-/uva%20113%20-%20Power%20of%20Cryptography.cpp][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]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=49
[2]: https://github.com/magdy-hasan/competitive-programming/blob/master/uva-/uva%20113%20-%20Power%20of%20Cryptography.cpp

1 Like

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

I think the test cases are weak!

1 Like