I want to code for calculating the value of pow(a,b)%MOD. I use C++ to code.
But the problem is the value of b can be very large. I know the log(b) time complexity method. But, the value of b might not fit in the data type "long long" of C++. For example b can be 1000000000 th Fibonacci number. Exact calculation of such a big number is itself, not possible (in time limits).
P.S. :
- pow(a,b) means a*a*a*a*... b times.
- X % MOD means the remainder obtained on dividing X by MOD.