Problem A. 我裂开了

Problem A. 我裂开了
Input file:
standard input
Output file:
standard output
Time limit:
1 second
Memory limit: 64 megabytes
Legendary GrandMaster ZHAN 有一句口头禅,叫做 我裂开了 。每当 ZHAN 遇到不会做的难题
时,就会说出这句口头禅,这时,他的能力值 n 就会裂开为 n 的所有 因子。例如,当 ZHAN 的能力值
12 时,喊一句 我裂开了 ,他的能力值就会分裂成 1 , 2 , 3 , 4 , 6 , 12 。当解决这道难题的时候,他的能力
值碎片又会聚合, ZHAN 新的能力值将变为能力值碎片之和 (1 + 2 + 3 + 4 + 6 + 12 = 28)( LevelU p )
现在, ZHAN 又遇到了一道不会做的难题,你知道 ZHAN 解决这道难题之后能力值会变为多少吗?
Input
输入一行一个整数 n (1 n 10 9 ) ,表示 ZHAN 当前的能力值。
Output
输出一行一个整数,表示 ZHAN 解决这道难题之后的能力值。
Example
standard input 12
standard output 28
Note
因子被定义为:假如整数 n 除以 m ,结果是无余数的整数,那么我们称 m 就是 n 的因子
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main()
{
    long int n;
    scanf("%ld", &n);
    long int i;
    long int sum = 0;
    for (i = 1; i <= n; i++)
    {
        if (n % i == 0)
            sum += i;
    }
    printf("%ld", sum);
}

你可能感兴趣的:(算法,java,开发语言)