void init() { int i; fac[0] =1; for(i =1; i <= p; i++) fac[i] = fac[i-1]*i % p; } llg pow(llg a, llg b) { llg tmp = a % p, ans =1; while(b) { if(b &1) ans = ans * tmp % p; tmp = tmp*tmp % p; b >>=1; } return ans; } llg C(llg n, llg m) { if(m > n) return0; return fac[n]*pow(fac[m]*fac[n-m], p-2) % p; } llg Lucas(llg n, llg m) { if(m ==0) return1; elsereturn (C(n%p, m%p)*Lucas(n/p, m/p))%p; }
void init() { p[0] = p[1] = I[0] = I[1] = 1; for (int i = 2 ; i < N ; ++ i) I[i] = (Q - Q / i) * I[Q % i] % Q; for (int i = 2 ; i < N ; ++ i) { p[i] = p[i - 1] * i % Q; I[i] = I[i - 1] * I[i] % Q; } } LL C(int x , int y) { return p[x] * I[y] % Q * I[x - y] % Q; }