1:埃筛写法 复杂度nlogn
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
//#define a(i,j) a[(i)*(m+2)+(j)] //m是矩阵的列数
const int M = 1e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y,int z){ee[++cnt].nxt=head[x],ee[cnt].to=y,ee[cnt].val=z,head[x]=cnt;}
*/
int phi[M];
void euler(int x)
{
phi[1]=0;
for(int i=2;i<=x;i++)phi[i]=i;
for(int i=2;i<=x;i++)
{
if(phi[i]!=i)continue;
for(int j=i;j<=x;j+=i)phi[j]=phi[j]*(i-1)/i;
}
for(int i=1;i<=x;i++)phi[i]=phi[i-1]+phi[i];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
euler(1000);
cin>>t;
for(int ca=1;ca<=t;ca++)
{
int x;
cin>>x;
cout<<ca<<" "<<x<<" "<<phi[x]*2+3<<endl;
}
return 0;
}
2:线性筛 复杂度On