competitive-programming-templates

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

View the Project on GitHub Misuki743/competitive-programming-templates

:warning: setfunc/fast_zeta_transform.cpp

Code

//note: to change to poset, flip the condition inside if statement. 

template<class T>
void fast_zeta_transform(vector<T> &vec, bool inverse = false) {
  for(int i = 0; (1 << i) < (int)vec.size(); i++)
    for(int j = 0; j < (int)vec.size(); j++)
      if (j >> i & 1)
        vec[j] += (inverse ? -vec[j ^ (1 << i)] : vec[j ^ (1 << i)]);
}
#line 1 "setfunc/fast_zeta_transform.cpp"
//note: to change to poset, flip the condition inside if statement. 

template<class T>
void fast_zeta_transform(vector<T> &vec, bool inverse = false) {
  for(int i = 0; (1 << i) < (int)vec.size(); i++)
    for(int j = 0; j < (int)vec.size(); j++)
      if (j >> i & 1)
        vec[j] += (inverse ? -vec[j ^ (1 << i)] : vec[j ^ (1 << i)]);
}
Back to top page