Advertisement
Guest User

Untitled

a guest
Feb 12th, 2013
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. typedef long long ll;
  2. typedef long double dbl;
  3.  
  4. ll mul( ll a, ll b, ll m )
  5. {
  6.   ll k = (ll)((dbl)a * b / m);
  7.   ll r = a * b - m * k;
  8.   while (r < 0)
  9.     r += m;
  10.   while (r >= m)
  11.     r -= m;
  12.   return r;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement