题解 | #质数因子#

质数因子

http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607

#include <iostream>
#include <math.h>
using namespace std;

int main(){
    long input;
    while(cin >> input){
        int tmp = input;
        for(int i=2; i<=(int)sqrt(input) && tmp!=1; i++){
            while(tmp%i==0){
                tmp /= i;
                cout<<i<<' ';
            }
        }
        if(tmp!=1){
            cout<<tmp<<' ';
        }
    }
    
    return 0;
}
全部评论

相关推荐

ResourceUtilization:四六级不愧是大学最有用的证之一
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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