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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.