competitive-programming-templates

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

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

:heavy_check_mark: numtheory/mu_vec.cpp

Verified with

Code

template<class T>
vc<T> mu_vec(int n) {
  vc<T> mu(n);
  if (n > 1) mu[1] = 1;
  for(int i = 2; i < n; i++) {
    int MPF = mpf(i);
    mu[i] = MPF == mpf(i / MPF) ? T(0) : -mu[i / MPF];
  }
  return mu;
}
#line 1 "numtheory/mu_vec.cpp"
template<class T>
vc<T> mu_vec(int n) {
  vc<T> mu(n);
  if (n > 1) mu[1] = 1;
  for(int i = 2; i < n; i++) {
    int MPF = mpf(i);
    mu[i] = MPF == mpf(i / MPF) ? T(0) : -mu[i / MPF];
  }
  return mu;
}
Back to top page