Lets say n,m and p are three long long integers.

i want to calculate (n*m)%p.

If (n*m) overflows the limit of long long then the answer would be wrong.
Moreover if i do ((n%p)*(m%p))%p then also there is no certainty of getting
correct answer.

How should i do this in C++ ?

-- 
Aamir Khan | 3rd Year  | Computer Science & Engineering | IIT Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to