Guest User

Untitled

a guest
Jan 16th, 2014
567
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. LL mult(LL a, LL b, LL c)
  2. {
  3.     if (a < b) swap(a, b);
  4.     LL r = 0, m = a;
  5.     for (int i = 0; i < 64; ++i)
  6.     {
  7.         if ((1LL<<i) > b) break;
  8.         if (b&1LL<<i) r = (r+m)%c;
  9.         m = (m*2)%c;
  10.     }
  11.     return r;
  12. }
RAW Paste Data