lmori's Library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub lmorinn/library

:heavy_check_mark: Superset/Subset Zeta/Möbius Transform
(math/set-function/ZetaMobiusTransform.hpp)

概要

todo

計算量

todo

Required by

Verified with

Code

template <class T>
vector<T> subset_zeta(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (t & (1 << i)) a[t] += a[t ^ (1 << i)];
    }
  }
  return a;
}

template <class T>
vector<T> subset_mobius(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (t & (1 << i)) a[t] -= a[t ^ (1 << i)];
    }
  }
  return a;
}

template <class T>
vector<T> superset_zeta(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (!(t & (1 << i))) a[t] += a[t | (1 << i)];
    }
  }
  return a;
}

template <class T>
vector<T> superset_mobius(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (!(t & (1 << i))) a[t] -= a[t | (1 << i)];
    }
  }
  return a;
}
#line 1 "math/set-function/ZetaMobiusTransform.hpp"

template <class T>
vector<T> subset_zeta(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (t & (1 << i)) a[t] += a[t ^ (1 << i)];
    }
  }
  return a;
}

template <class T>
vector<T> subset_mobius(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (t & (1 << i)) a[t] -= a[t ^ (1 << i)];
    }
  }
  return a;
}

template <class T>
vector<T> superset_zeta(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (!(t & (1 << i))) a[t] += a[t | (1 << i)];
    }
  }
  return a;
}

template <class T>
vector<T> superset_mobius(int n, vector<T> a) {
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      if (!(t & (1 << i))) a[t] -= a[t | (1 << i)];
    }
  }
  return a;
}
Back to top page