https://blog.csdn.net/CPOHUI/article/details/78667490
https://blog.csdn.net/x_i_y_u_e/article/details/46365549
#include<iostream>
#include<vector>
using namespace std;
const int maxt = 1000000;
vector<bool>prime;
int main()
{
prime.resize(maxt,1);
prime[0] = prime[1] = 0;//1是素数,0是非素数
int sum = 0;
for(int i = 2; i*i <= prime.size(); i++)
{
if(prime[i] == 1)
for(int j = i*2; j <= prime.size(); j += i)
{
prime[j] = 0;
}
}
for(int i = 2; i <= 100; i++){
if(prime[i] == 1) cout << i << " ";
}
return 0;
}
https://blog.csdn.net/Dinosoft/article/details/5829550 线性素数筛