Does anyone know how I can solve this problem? Unfortunately, I can't find any editorials/solutions online, and I've been stuck on this problem for some time now :).
I've tried using BigInteger, etc in Java, with no luck. So I would love to see how someone else has done it.
Here's the problem: https://www.spoj.com/problems/PIB/