Advertisement
istinishat

bigmod

Apr 20th, 2017
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int bigmod(long long a,long long p)
  2. {
  3.     long long ret = 1;
  4.     while(p) {
  5.         if(p & 1) ret = ret * a % mod;
  6.         a = a * a % mod;
  7.         p >>= 1;
  8.     }
  9.     return ret;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement