质数因子

质数因子

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

import java.util.*;

public class Main 
{
    public Main() 
    {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLong()) {
            long n = in.nextLong();
            StringBuilder output = new StringBuilder();
            for (int i = 2; i <= n; i++) {
                while (n % i == 0) {
                    output.append(i).append(" ");
                    n /= i;
                }
            }
            System.out.println(output);
       }
    }

    public static void main(String[] args) 
    {
        Main solution = new Main();
    }
}
全部评论
也超时了。。哎。。你们先运行通过了再发评论比较好吧 兄弟
点赞 回复 分享
发布于 2021-03-07 16:15

相关推荐

11-04 19:05
已编辑
东莞城市学院 单片机
不知道怎么取名字_:你这个要实习两年?哪有这么久的,感觉就是即使你毕业了,但还按实习的话,是不是不用给你缴社保公积金啥的
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

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