#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int Read(){
int x=0,f=1; char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1; c=getchar();
}
while(c>='0'&&c<='9')
x=(x<<3)+(x<<1)+c-'0',c=getchar();
return x*f;
}
const LL maxn=1000007;
int n,tot;
int phi[maxn],pim[maxn>>1];
LL ans;
inline void First(){
for(int i=2;i<=n+1;i++){
if(!phi[i])
phi[i]=i-1,
pim[++tot]=i;
for(int j=1;j<=tot&&pim[j]*i<maxn;j++)
if(i%pim[j]==0){
phi[i*pim[j]]=phi[i]*pim[j];
break;
}else
phi[i*pim[j]]=phi[i]*(pim[j]-1);
}
}
int main () {
n=Read();
First();
for(int i=1;i*i<=n;i++)
if(n%i==0)
if(i*i==n)
ans+=phi[i+1];
else
ans+=phi[i+1]+phi[n/i+1];
printf("%lld",ans+1>>1);
return 0;
}
P4388 付公主的矩形
最新推荐文章于 2024-09-13 17:43:09 发布