题
http://codevs.cn/problem/2296/
题解
水题,ans=∑phi(i)+1,其中i∈[1,N-1]
代码
//欧拉函数
#include <cstdio>
#include <algorithm>
#define maxn 50000
using namespace std;
int phi[maxn], N, ans;
void shai()
{
int i, j;
for(i=1;i<=N;i++)phi[i]=i;
for(i=2;i<=N;i++)
if(phi[i]==i)
for(j=i;j<=N;j+=i)phi[j]=phi[j]-phi[j]/i;
}
int main()
{
int i;
scanf("%d",&N);
shai();
for(i=1;i<N;i++)ans+=phi[i];
printf("%d\n",ans*2+1);
return 0;
}