【hdu - 3501 (数论、欧拉函数)】
2012-07-13 20:36
351 查看
Calculation 2
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1121 Accepted Submission(s): 479
[align=left]Problem Description[/align]
Given a positive integer N, your task is to calculate the sum of the positive integers less than N which are not coprime to N. A is said to be coprime to B if A, B share no common positive divisors except 1.
[align=left]Input[/align]
For each test case, there is a line containing a positive integer N(1 ≤ N ≤ 1000000000). A line containing a single 0 follows the last test case.
[align=left]Output[/align]
For each test case, you should print the sum module 1000000007 in a line.
[align=left]Sample Input[/align]
3
4
0
[align=left]Sample Output[/align]
0
2
[align=left]Author[/align]
GTmac
[align=left]Source[/align]
2010 ACM-ICPC Multi-University Training Contest(7)——Host by HIT
[align=left]Recommend[/align]
zhouzeyong
// Project name : 3501 ( Calculation 2 ) // File name : main.cpp // Author : Izumu // Date & Time : Fri Jul 13 17:14:43 2012 #include <iostream> #include <stdio.h> #include <string> #include <math.h> #include <algorithm> using namespace std; //////////////////////////////////////////////////////////////////////// typedef unsigned long long int longint; //////////////////////////////////////////////////////////////////////// longint phi(longint num) { longint sum = 1; for (longint i = 2; i <= sqrt((double long)num); i++) { if (num % i == 0) { while (num % i == 0) { sum *= i; num /= i; } sum /= i; sum *= (i - 1); } } if (num != 1) { sum *= (num - 1); } return sum; } //////////////////////////////////////////////////////////////////////// int main() { longint number; while (cin >> number && number) { cout << ((number - 1) * number / 2 - number * phi(number) / 2) % 1000000007 << endl; } return 0; } // end // ism
相关文章推荐
- 【数论-欧拉函数】HDU 3501 Calculation 2 ( 与n不互质的数的和 )
- HDU 3501 数论 欧拉函数的应用
- HDU 4002 Find the maximum(数论-欧拉函数)
- (hdu 2588 gcd)<数论—欧拉函数>
- hdu 4279Number(数论:推论+欧拉函数性质)
- hdu 3501 Calculation 2 (欧拉函数)
- HDU 3501 Calculation 2(欧拉函数)
- HDU 2588 数论 欧拉函数
- hdu 1695 综合数论 欧拉函数 分解质因子 容斥原理 打印素数表 帅呆了的一个题目 详解
- hdu 1286:找新朋友(数论,欧拉函数)
- HDU 3501 Calculation 2 (欧拉函数||容斥原理)
- HDU 3501 Calculation 2(欧拉函数)
- hdu 3501(欧拉函数)
- [HDU]3501 Calculation 2 [欧拉函数之求和]
- HDU -- 3501 Calculation 2 【欧拉函数性质的应用】
- HDU 2588 GCD [欧拉函数]【数论】
- hdu 3501 Calculation 2 (欧拉函数)
- HDU 4279 2012网络赛Number(数论 欧拉函数结论约数个数)
- Description has only two Sentences HDU - 3307(欧拉函数)(数论定理)
- HDU 3501(欧拉函数)