其他分享
首页 > 其他分享> > [luogu2303]Longge的问题

[luogu2303]Longge的问题

作者:互联网

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 ll n,ans;
 5 ll phi(ll n){
 6     ll ans=n;
 7     for(ll i=2;i*i<=n;i++){
 8         if (n%i==0)ans=ans/i*(i-1);
 9         while (n%i==0)n/=i;
10     }
11     if (n>1)ans=ans/n*(n-1);
12     return ans;
13 }
14 int main(){
15     scanf("%lld",&n);
16     ll m=(ll)sqrt(n);
17     for(ll i=1;i<=m;i++)
18         if (n%i==0)ans+=i*phi(n/i)+n/i*phi(i);
19     if (m*m==n)ans-=m*phi(m);
20     printf("%lld",ans);
21 }
View Code

 

标签:Longge,ll,long,问题,int,luogu2303,sqrt,ans,include
来源: https://www.cnblogs.com/PYWBKTDA/p/11272072.html