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/phi_vec.cpp

Verified with

Code

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