Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll modularExponentiation(ll x,ll n,ll M)
- {
- ll result=1;
- while(n>0)
- {
- if(n % 2 ==1)
- result=(result * x)%M;
- x=(x*x)%M;
- n=n/2;
- }
- return result;
- }
- ll modinv(ll A)
- {
- return modularExponentiation(A,m-2,m);
- }
Add Comment
Please, Sign In to add comment