The problem is this:
http://codeforces.com/problemset/problem/300/C
Thanks to it, I managed to understand a bit better the usage and concept of modular multiplicative inverse.
Namely, if we want to compute x^(-1) % (M=a big prime number) then we can use Euler's Theorem and do:
x^(M-2) % M and compute it by fast exponentiantion, is this so?
However, many contestants there used this function:
long long int big_mod(long long int i, long long int j)
{
if(j==0)
return 1;
long long int x=big_mod(i,j>>1);
x=(x*x)%mod;
if(j&1)
return (x*i)%mod;
return x;
}
My doubt is:
Is this function doing the same job as the standard fast exponentiation function? If not, why?
Thanks in advance,
Bruno