Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll mpow(ll base, ll exp, ll mod)
- {
- ll res = 1;
- while(exp) {
- if(exp & 1) res = (res * base) % mod;
- base = (base * base) % mod;
- exp >>= 1;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement