Aamir: Check out the thread "Modular arithmetic + Combinatorics"
recently in this newsgroup.

Dave

On Nov 3, 1:29 pm, Aamir Khan <[email protected]> wrote:
> Lets say i want to calculate (1000C500)%MOD.
>
> *My Code : *
> *
> *
>     long long ans=n;
>     for(int i=1;i<=r;i++) {
>         ans=(ans*(n-i+1))/i;
>         ans = ans%MOD;
>     }
>
> But when the ans inside the loop starts exceeding MOD and you take
> ans=ans%MOD then you cannot be sure to get the correct answer..
>
> How to deal with this situation ?
>
> --
> 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