欧拉函数。。。。。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=
50000+
10;
int pp[maxn];
int sum[maxn];
int n;
void ola()
{
memset(pp,0,
sizeof(pp));
memset(sum,0,
sizeof(sum));
pp[1]=
1;
for(
int i=
2;i<=maxn;i++
)
if(!
pp[i])
{
for(
int j=i;j<=maxn;j+=
i)
{
if(!pp[j]) pp[j]=
j;
pp[j]=pp[j]/i*(i-
1);
}
}
for(
int i=
1;i<=maxn;i++
)
sum[i]=pp[i]+sum[i-
1];
}
int main()
{ ola();
while(~scanf(
"%d",&n)&&n!=
0)
{
printf("%d\n",sum[n]*
2-
1);
}
return 0;
}
转载于:https://www.cnblogs.com/Wangwanxiang/p/6765058.html
相关资源:数据结构—成绩单生成器
转载请注明原文地址: https://win8.8miu.com/read-1495583.html