library

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

View the Project on GitHub matumoto1234/library

:warning: math/count-factor.hpp

Depends on

Required by

Code

#pragma once

#include "./base.hpp"

#include <cstdint>
#include <vector>

namespace matumoto {
  vector<int> count_factor(int N) {
    constexpr int INF = INT32_MAX / 2;
    vector<int> table(N + 1, 0);

    for (int i = 2; i <= N; i++) {
      if (table[i])
        continue;
      table[i] = 1;
      for (int j = 2 * i; j <= N; j += i) {
        if (j % (i * i) == 0)
          table[j] = -INF;
        else
          table[j]++;
      }
    }
    return table;
  }
} // namespace matumoto
#line 2 "math/count-factor.hpp"

#line 2 "math/base.hpp"

namespace matumoto {
  using namespace std;
  using ll = long long;
} // namespace matumoto
#line 4 "math/count-factor.hpp"

#include <cstdint>
#include <vector>

namespace matumoto {
  vector<int> count_factor(int N) {
    constexpr int INF = INT32_MAX / 2;
    vector<int> table(N + 1, 0);

    for (int i = 2; i <= N; i++) {
      if (table[i])
        continue;
      table[i] = 1;
      for (int j = 2 * i; j <= N; j += i) {
        if (j % (i * i) == 0)
          table[j] = -INF;
        else
          table[j]++;
      }
    }
    return table;
  }
} // namespace matumoto
Back to top page