I am trying to solve https://www.codechef.com/problems/TPRODUCT problem. The solution is simple. But storing number in long long is not enough. So I studied the approach of the editorial. It takes logarithm to solve it. I have two doubts.

The logarithmic part is not giving correct answer as floating point operations are not accurate. For second test case, the answer is 105, I am getting 104. Here’s my code without modulo operation.
http://ideone.com/cEHyJ4
What can I do to fix it? 
How do I perform the modulo operation on a exponentiation where power is a floating point number? I know modular exponentiation but there base and exponents are integers. What can be done for floating point?