您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: