What are the best ways to calculate nCr (n choose r) mod m where m is a large prime and n, r are smaller than m?
I was referring to this problem: http://www.spoj.com/problems/RIVALS/I got AC with pre-calculation of factorial values with PyPy but still TLE with Pyth 2.7Any ideas?
google.com/#q=fast+n+choose+modulo