This documentation is automatically generated by online-judge-tools/verification-helper
#include "lib/eratosthenes-sieve.hpp"
TBD
TBD
TBD
/**
* @brief sieve of Eratosthenes (エラトステネスの篩)
* @docs docs/eratosthenes-sieve.md
*/
template<typename T>
class EratosthenesSieve {
public:
T size;
std::vector<bool> p;
EratosthenesSieve(T size) : size(size), p(size + 1, true) {
p[0] = p[1] = false;
for (T i = 2; i * i <= size; i++) if (p[i])
for (T j = i * i; j <= size; j += i)
p[j] = false;
}
std::vector<T> get_primes() const {
std::vector<T> ret;
for (T i = 0; i <= size; i++)
if (p[i]) ret.push_back(i);
return ret;
}
};
#line 1 "lib/eratosthenes-sieve.hpp"
/**
* @brief sieve of Eratosthenes (エラトステネスの篩)
* @docs docs/eratosthenes-sieve.md
*/
template<typename T>
class EratosthenesSieve {
public:
T size;
std::vector<bool> p;
EratosthenesSieve(T size) : size(size), p(size + 1, true) {
p[0] = p[1] = false;
for (T i = 2; i * i <= size; i++) if (p[i])
for (T j = i * i; j <= size; j += i)
p[j] = false;
}
std::vector<T> get_primes() const {
std::vector<T> ret;
for (T i = 0; i <= size; i++)
if (p[i]) ret.push_back(i);
return ret;
}
};