题解 | 1=N

1=N

https://www.nowcoder.com/practice/31469f8503c24914acd5c0290ad4dfbb

#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);

    if(n == 1){
        printf("0\n");
        return 0;
    }
    if(n < 6){
        printf("%d", n);
        return 0;
    }
    int temp = n;
    long long num = 0;
    for(int i = 2; i*i <= temp; i++){       
        while(temp % i == 0){
            temp = temp / i;
            num += i;
        }
    }
    if(temp > 1){
        num += temp;
    }
    printf("%lld", num);
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务