打1000000要 3.580s;附超级读取会杀时间(滑稽)
#include <iostream>
#include <math.h>
#include<string.h>
#define MAXN 1000000
bool check[MAXN];
int prime[MAXN],t;
using namespace std;
int main()
{
t=0;
memset(check, 0, sizeof check);
for (int i = 2; i <= sqrt(MAXN); i++) {
if (check[i]) continue;
for (int j = i * i; j < MAXN; j += i) check[j] = 1;
}
for (int i = 2; i < MAXN; i++)
if (!check[i]) prime[t++] = i;
for (int i = 0; i < t; i++)
cout<<prime[i]<<" ";
}
inline char gc()
{
static char buff[100000000],*S=buff,*T=buff;
return S==T&&(T=(S=buff)+fread(buff,1,100000000,stdin),S==T)?EOF:*S++;
}