HayatoY's Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub HayatoYagi/library

:warning: Math/ModInt-Combination.cpp

Code

vector<mint> fact(n+1,1);
REP(i,n)fact[i+1] = fact[i] * (i+1);
vector<mint> ifact(n+1);
ifact[n] = fact[n].inv();
FORR(i,n,1)ifact[i-1] = ifact[i] * i;
auto comb = [&](int32 n, int32 r){
  if(n < r)return mint(0);
  return fact[n] * ifact[n-r] * ifact[r];
};
#line 1 "Math/ModInt-Combination.cpp"
vector<mint> fact(n+1,1);
REP(i,n)fact[i+1] = fact[i] * (i+1);
vector<mint> ifact(n+1);
ifact[n] = fact[n].inv();
FORR(i,n,1)ifact[i-1] = ifact[i] * i;
auto comb = [&](int32 n, int32 r){
  if(n < r)return mint(0);
  return fact[n] * ifact[n-r] * ifact[r];
};
Back to top page