Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll power(ll x, ll y)
- {
- ll res = 1;
- while (y > 0)
- {
- if (y & 1)
- res = (res * x) % MOD;
- y = y >> 1;
- x = (x * x) % MOD;
- }
- return res;
- }
- ll modInv(ll x)
- {
- return power(x, MOD - 2);
- }
- ll C(ll n, ll r)
- {
- ll ans = fact[n] % MOD;
- ans = (ans * modInv(fact[n - r])) % MOD;
- ans = (ans * modInv(fact[r])) % MOD;
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement