Luzhiled's Library

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

View the Project on GitHub ei1333/library

:question: Subproduct Tree
(math/fps/subproduct-tree.hpp)

Required by

Verified with

Code

/**
 * @brief Subproduct Tree
 */
template< template< typename > class FPS, typename Mint >
vector< FPS< Mint > > subproduct_tree(const FPS< Mint > &xs) {
  int n = (int) xs.size();
  int k = 1;
  while(k < n) k <<= 1;
  vector< FPS< Mint > > g(2 * k, {1});
  for(int i = 0; i < n; i++) g[k + i] = {-xs[i], Mint(1)};
  for(int i = k; i-- > 1;) g[i] = g[i << 1] * g[i << 1 | 1];
  return g;
}
#line 1 "math/fps/subproduct-tree.hpp"
/**
 * @brief Subproduct Tree
 */
template< template< typename > class FPS, typename Mint >
vector< FPS< Mint > > subproduct_tree(const FPS< Mint > &xs) {
  int n = (int) xs.size();
  int k = 1;
  while(k < n) k <<= 1;
  vector< FPS< Mint > > g(2 * k, {1});
  for(int i = 0; i < n; i++) g[k + i] = {-xs[i], Mint(1)};
  for(int i = k; i-- > 1;) g[i] = g[i << 1] * g[i << 1 | 1];
  return g;
}
Back to top page