AcWing 201. 可见的点
原题链接
简单
作者:
最后五分钟
,
2024-04-11 17:24:02
,
所有人可见
,
阅读 5
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
const int N=1010;
typedef pair<int,int> PII;
vector<int> p;
int st[N],phi[N];
void getp(int n)
{
for(int i=2;i<=n;i++)
{
if(!st[i])
{
p.push_back(i);
phi[i]=i-1;
}
for(int j=0;p[j]<=n/i;j++)
{
st[i*p[j]]=1;
if(i%p[j]==0)
{
phi[i*p[j]]=phi[i]*p[j];
break;
}
else phi[i*p[j]]=phi[i]*(p[j]-1);
}
}
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
getp(1001);
for(int i=1;i<=t;i++)
{
int x;
cin>>x;
int sum=3;
for(int j=2;j<=x;j++)sum+=2*phi[j];
cout<<i<<" "<<x<<" "<<sum<<endl;
}
return 0;
}