library

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

View the Project on GitHub maspypy/library

:heavy_check_mark: setfunc/count_surjection.hpp

Verified with

Code

template<typename mint>
mint count_surjection(ll n, ll m) {
  if (n < m) return 0;
  mint res = 0;
  FOR(i, m + 1) {
    mint sgn = ((m - i) & 1 ? -1 : 1);
    res += mint(i).pow(n) * C<mint>(m, i) * sgn;
  }
  return res;
}
#line 1 "setfunc/count_surjection.hpp"
template<typename mint>
mint count_surjection(ll n, ll m) {
  if (n < m) return 0;
  mint res = 0;
  FOR(i, m + 1) {
    mint sgn = ((m - i) & 1 ? -1 : 1);
    res += mint(i).pow(n) * C<mint>(m, i) * sgn;
  }
  return res;
}
Back to top page