class Euler {
private:unsigned int cnt;//素数筛范围大小std::vector<int> sieve;std::vector<bool> composite;
public:Euler() {}Euler(const unsigned int x) {this -> cnt = x;composite.resize(x * 2, false); sieve.emplace_back(0);}//进行cnt范围内筛选void Sifting(){for(int i = 2; i <= cnt; i++){if(!composite[i])sieve.emplace_back(i);for(int j = 1; sieve[j] * i <= cnt; j++){composite[sieve[j] * i] = true;if(i % sieve[j] == 0)break;}}}//快速判断x是否为素数bool Determine_prime(const unsigned int x) {if (x == 1)return false;if (x == 2 || x == 3)return true;if (x % 6 != 1 && x % 6 != 5)return false;for (int i = 5; i * i <= x; i += 6)if (x % i == 0 || x % (i + 2) == 0)return false;return true;}//返回cnt范围内第x个素数,没有返回0unsigned int Re_sieve(const unsigned int x){if(x > sieve.size())return *sieve.begin();return this -> sieve[x];}//返回cnt范围内素数个数unsigned int Resum_sieve(){return this -> sieve.size() - 1;}
};