For C (n, k) modulo, k350c Mold
2016.1.26
Method 1: Calculate the multiplication inverse element based on the definition.
Method 2: Use n! Mod p, which can be solved based on the definition of C (n, k) and multiplication inverse element.
Method 3: solving with Lucas Theorem
NOTE: In the case that the C (n, k) modulo p is equal to 0, the above method does not work, so we need to determine it.
Example of Special Determination Method: for example, if the number of factor p in the numerator is e1 and the number of factor p in the denominator is e2, then When e1 = e2, the module p cannot be 0, continue. If e1> e2, p is 0 and 0 is returned directly.
For example, when method 3 is adopted, there is such a sentence: C (a, B) the necessary and sufficient condition for mod p not equal to 0 is that every bit of a in p-base is not smaller than the corresponding bit of B in p-base, C (a, B) the necessary and sufficient condition for p to be equal to 0 is that a has at least one bit smaller than B in p base.
It doesn't matter if you don't understand it. Read this question and you will understand: the Cong examination (mainly the part of the Lucas theorem)