Untitled
user_8537553
plain_text
a year ago
668 B
1
Indexable
Never
class Solution { public int solve(int A, int B, int C) { long nf = findFactorial(A,C); long rf = findFactorial(B,C); long nrf = findFactorial(A-B,C); long fpr = fastPower(rf, C-2,C); long fpnr = fastPower(nrf,C-2,C); return Convert.ToInt32((nf/rf)/nrf); } long fastPower(long N,int P,int C) { if(P==0) return 1; if(P%2==0) return fastPower(N*N %C ,P/2,C); else return N * fastPower(N*N % C, P/2,C) % C; } long findFactorial(long N,int C) { if(N<=0) return 1; return (N * findFactorial(N-1,C))%C ; } }