题解 | #质因数的个数#

质因数的个数

https://www.nowcoder.com/practice/20426b85f7fc4ba8b0844cc04807fbd9

#include <iostream>
using namespace std;

int main() {
    int n;
    while(cin>>n){
        int cnt=0;
        for(int i=2;i<=n/i;i++){
            if(n%i==0){
                while(n%i==0){
                    n/=i;
                    cnt++;
                }
            }
        }
        if(n>1) cnt++;
        cout<<cnt<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

用微笑面对困难:只要你保证项目和获奖都是真的就行尤其是“对战,总负责人”啊这些套职,基本上队员,打杂的都这么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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