标签:
Time Limit: 1000MS | Memory Limit: 32768KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
3 4 0
Sample Output
0 2
/* Author: 2486 Memory: 1408 KB Time: 15 MS Language: G++ Result: Accepted VJ RunId: 4178187 Real RunId: 14209894 */ #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long LL; const LL mod=1000000007; LL n; LL getOL(LL x) { LL res=x; for(int i=2; i<=sqrt(x); i++) { if(x%i==0) { res=res/i*(i-1); while(x%i==0) { x/=i; } } } if(x>=2) { res=res/x*(x-1); } return res; } int main() { while(~scanf("%I64d",&n),n) { LL ans1=n*(n+1)/2-n;//n前,所以n不包括在求和内 LL ans2=getOL(n)*n/2; printf("%I64d\n",(ans1-ans2)%mod); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/qq_18661257/article/details/47099665