标签:
Description
Input
Output
Sample Input
Sample Output
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 using namespace std; 5 const int mod=1000000007; 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n)!=EOF&&n) 10 { 11 long long temp=n,eular=1; 12 long long ans=(temp*(temp+1)/2)%mod; 13 for(int i=2;i*i<=temp;i++) 14 if(temp%i==0) 15 { 16 temp/=i; 17 eular*=i-1; 18 while(temp%i==0) 19 { 20 temp/=i; 21 eular*=i; 22 } 23 } 24 if(temp>1) eular*=temp-1; 25 eular%=mod; 26 temp=n; 27 long long w=(eular*temp/2)%mod; 28 ans-=w; 29 ans-=n; 30 while(ans<0) ans+=mod; 31 printf("%lld\n",ans); 32 } 33 return 0; 34 }
标签:
原文地址:http://www.cnblogs.com/I-love-HLD/p/4624723.html