This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub maspypy/library
#include "setfunc/and_convolution.hpp"
#include "setfunc/zeta.hpp" template <typename T> vc<T> and_convolution(vc<T> A, vc<T> B) { superset_zeta(A); superset_zeta(B); FOR(i, len(A)) A[i] *= B[i]; superset_mobius(A); return A; }
#line 2 "setfunc/zeta.hpp" template <typename T> void superset_zeta(vc<T>& A) { int log = topbit(len(A)); assert(1 << log == len(A)); FOR(n, log) FOR(s, 1 << log) { int t = s ^ (1 << n); if (s < t) A[s] += A[t]; } } template <typename T> void superset_mobius(vc<T>& A) { int log = topbit(len(A)); assert(1 << log == len(A)); FOR(n, log) FOR(s, 1 << log) { int t = s ^ (1 << n); if (s < t) A[s] -= A[t]; } } template <typename T> void subset_zeta(vc<T>& A) { int log = topbit(len(A)); assert(1 << log == len(A)); FOR(n, log) FOR(s, 1 << log) { int t = s ^ (1 << n); if (s > t) A[s] += A[t]; } } template <typename T> void subset_mobius(vc<T>& A) { int log = topbit(len(A)); assert(1 << log == len(A)); FOR(n, log) FOR(s, 1 << log) { int t = s ^ (1 << n); if (s > t) A[s] -= A[t]; } } #line 2 "setfunc/and_convolution.hpp" template <typename T> vc<T> and_convolution(vc<T> A, vc<T> B) { superset_zeta(A); superset_zeta(B); FOR(i, len(A)) A[i] *= B[i]; superset_mobius(A); return A; }