Luzhiled's Library

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

View the Project on GitHub ei1333/library

:x: Stirling First(第一種スターリング数)
(math/fps/stirling-first.hpp)

Verified with

Code

/**
 * @brief Stirling First(第一種スターリング数)
 */
template< template< typename > class FPS, typename Mint >
FPS< Mint > stirling_first(int N) {
  if(N <= 0) return {Mint(1)};
  auto f = stirling_first< FPS, Mint >(N >> 1);
  f *= f.taylor_shift(-(N >> 1));
  if(N & 1) f = (f << 1) - f * (N - 1);
  return f;
}
#line 1 "math/fps/stirling-first.hpp"
/**
 * @brief Stirling First(第一種スターリング数)
 */
template< template< typename > class FPS, typename Mint >
FPS< Mint > stirling_first(int N) {
  if(N <= 0) return {Mint(1)};
  auto f = stirling_first< FPS, Mint >(N >> 1);
  f *= f.taylor_shift(-(N >> 1));
  if(N & 1) f = (f << 1) - f * (N - 1);
  return f;
}
Back to top page