题解 | 分解质因数

分解质因数

https://www.nowcoder.com/practice/35723516d6f841ca8869ecbcf3ddacaf

#include <iostream>
using namespace std;

int main() {
    long long x;
    cin>>x;
    int i=2;
    while(x>=1&&i<=x)
    {
        if(x%i==0) {x/=i;cout<<i<<" ";}
        else i++;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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