标签:number pre while include lse std desc bsp sum
Description
Input
Output
Sample Input
2 6
Sample Output
3 15
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 #define ll long long int 6 using namespace std; 7 ll eular(ll n) 8 { 9 ll i,ret=n; 10 for(i=2; i<=sqrt(n); i++) 11 { 12 if(n%i==0) 13 { 14 ret=ret/i*(i-1); 15 while(n%i==0) 16 { 17 n/=i; 18 } 19 } 20 } 21 if(n>1) 22 { 23 ret=ret/n*(n-1); 24 } 25 return ret; 26 } 27 int main() 28 { 29 ll n,num,i,j; 30 ll ans; 31 while(scanf("%lld",&n)!=EOF) 32 { 33 34 ans=eular(n)+n; 35 for(i=2;i<=sqrt(n);i++) 36 { 37 if(n%i==0) 38 { 39 if(i*i==n) 40 { 41 ans=ans+eular(i)*i; 42 } 43 else 44 { 45 ans=ans+eular(i)*(n/i); 46 ans=ans+eular(n/i)*i; 47 } 48 } 49 } 50 printf("%lld\n",ans); 51 } 52 return 0; 53 }
标签:number pre while include lse std desc bsp sum
原文地址:https://www.cnblogs.com/wkfvawl/p/9640525.html