文章

6

粉丝

553

获赞

9

访问

38.1k

头像
BigInteger.class
P1182 北京大学上机题
发布于2022年7月5日 16:47
阅读数 4.0k

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            BigInteger dividend = scan.nextBigInteger();//被除数
            boolean flag = false;
            for (int i = 2; i < 10; ++i) {
                BigInteger divisor = BigInteger.valueOf(i);//除数
                if (dividend.remainder(divisor) == BigInteger.valueOf(0)) {//整除
                    System.out.print(divisor + " ");
                    flag = true;
                }
            }
            if (!flag) System.out.print("none");//被除数在 2~9 无因子
            System.out.println();
        }
    }

}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发