#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
inline LL phi(int n){
if(n==1)return 1;
LL ans=1;
for(LL i=2;i*i<=n;i++)
if(n%i==0){
int k=0;
while(n%i==0)k++,n/=i;
ans*=i-1;
for(int j=2;j<=k;j++)ans*=i;
}
if(n>1)ans*=n-1;
return ans;
}
int n;
long long ans;
int main(){
scanf("%d",&n);
for(int i=1;i*i<=n;i++)
if(n%i==0){
ans+=(long long)i*phi(n/i);
if(i*i<n)ans+=(long long)n/i*phi(i);
}
printf("%lld",ans);
return 0;
}
2705: [SDOI2012]Longge的问题
最新推荐文章于 2020-12-22 02:56:21 发布