UVA10830 A New Function【数学】
2018-02-12 20:41
507 查看
We all know that any integer number N is divisible by 1 and N. That is why these two numbers are not the actual divisors of any numbers. The function SOD(n) (Sum of divisors) is defined as the summation of all the actual divisors of an integer number n. For example SOD(24)=2+3+4+6+8+12=35. The function CSOD(n) (cumulative SOD) of an integer n, is defined as below:
Given the value of n, your job is to find the value of CSOD(n).
Input
The input file contains at most 50 lines of input. Each line contains an integer n (0 ≤ n ≤ 2000000000). Input is terminated by a line where the value of n = 0. This line should not be processed.
Output
For each line of input produce one line of output. This line should contain the serial of output followed by the value of CSOD(n). Look at the output for sample input for details. You can safely assume that any output number fits in a 64-bit signed integer.
Sample Input
2
100
200000000
Sample Output
Case 1: 0
Case 2: 3150
Case 3: 12898681201837053
问题链接:UVA10830 A New Function
问题简述:(略)
问题分析:先占个位置。
程序说明:(略)
题记:(略)
参考链接:(略)
AC的C++语言程序如下:/* UVA10830 A New Function */
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, caseno = 0, q;
long long sum, d;
while(~scanf("%d", &n) && n) {
q = sqrt(n);
sum = 0;
for(int i=2; i<=q; i++) {
d = n / i;
sum += d * (d + 1) / 2 - 1;
sum += (d - q) * i;
}
printf("Case %d: %lld\n", ++caseno, sum);
}
return 0;
}
Given the value of n, your job is to find the value of CSOD(n).
Input
The input file contains at most 50 lines of input. Each line contains an integer n (0 ≤ n ≤ 2000000000). Input is terminated by a line where the value of n = 0. This line should not be processed.
Output
For each line of input produce one line of output. This line should contain the serial of output followed by the value of CSOD(n). Look at the output for sample input for details. You can safely assume that any output number fits in a 64-bit signed integer.
Sample Input
2
100
200000000
Sample Output
Case 1: 0
Case 2: 3150
Case 3: 12898681201837053
问题链接:UVA10830 A New Function
问题简述:(略)
问题分析:先占个位置。
程序说明:(略)
题记:(略)
参考链接:(略)
AC的C++语言程序如下:/* UVA10830 A New Function */
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, caseno = 0, q;
long long sum, d;
while(~scanf("%d", &n) && n) {
q = sqrt(n);
sum = 0;
for(int i=2; i<=q; i++) {
d = n / i;
sum += d * (d + 1) / 2 - 1;
sum += (d - q) * i;
}
printf("Case %d: %lld\n", ++caseno, sum);
}
return 0;
}
相关文章推荐
- uva 10830 A New Function
- UVA 10990(Another New Function)欧拉函数
- UVA, 10990 Another New Function
- Linux C Function()参考之常用数学函数篇
- 数学专项number_theory:UVa 11105
- UVa 321 - The New Villa
- HDU 1420 Prepared for New Acmer(数学题)
- UVa 294 - Divisors(数学)
- hash function/ hash table 背后的数学基础(二)
- uva 10280 - Old Wine Into New Bottles
- The queue uvalive 5002 light 1382 uva 12257 (dfs加组合数学)
- 数学专项number_theory:UVa 10951
- Good Bye 2017 D.New Year and Arbitrary Arrangement - 数学
- UVa 10250 The Other Two Trees(数学问题)
- uva 573(数学)
- setFontColor=new Function("x","document.fgColor=x");函数对象,相当于
- 数学,计数(数三角形,uva 11401)
- uva 11044(数学)
- VC GDI+: error C2660: 'new' : function does not take 3 parameters
- uva 568(数学)