https://ac.nowcoder.com/acm/contest/327/H

C++版本一

std

题解:素数 构造 欧拉函数

参考文章:https://blog.csdn.net/weixin_43272781/article/details/85558253

 

#include <bits/stdc++.h>
using namespace std;
#define maxn 1000000
int pri[maxn+5];
void getprime()
{
    int i,j;
    for (i=2;i<=maxn;i++)
    {
        if (pri[i]==0) pri[++pri[0]]=i;
        for (j=1;j<=pri[0] && pri[j]<=maxn/i;j++)
        {
            pri[pri[j]*i]=1;
            if (i%pri[j]==0) break;
        }
    }
}
 
int main()
{
    getprime();
    for (int i=1;i<=2000;i++)
    {
        printf("%d\n",pri[i]*pri[4001-i]);
    }
    return 0;
}