详细见:http://blog.csdn.net/nk_test/article/details/46242401
#includeusing namespace std;const int maxn = 1e7;bool vis[maxn];int prime[maxn];int f(int n)//计算从1到n的素数个数{ int cnt =0; memset(vis,0,sizeof(vis)); for(int i=2;i<=n;i++) { if(!vis[i]) prime[cnt++] = i; for(int j=0;j >n; cout< <