题解 | 矩形游戏

矩形游戏

https://www.nowcoder.com/practice/5b6c2c824a434b55a5e3b77619c54a90

#include <stdio.h>
typedef long long ll;

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

    ll ans = n;
    for(ll i = 2; i*i <= n; i++){
        while(n % i == 0){
            n/= i;
            ans += n;
        }
    }
    if (n > 1)
        ans += 1;
    printf("%lld", ans);
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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