当前位置:网站首页>1096 big beautiful numbers (15 points)

1096 big beautiful numbers (15 points)

2022-08-11 07:48:00 dumb bit

题目要求:
在这里插入图片描述
代码:

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        //
        for(int i = 0; i < n;i++) {
    
            int num = scan.nextInt();
            ArrayList<Integer> yinShu = new ArrayList<>();
            //Find all factors that are not identical
            for (int j = 1; j <= num; j++) {
    
                if (num%j == 0 && !yinShu.contains(j)){
    
                    yinShu.add(j);
                }
            }
            int size = yinShu.size();
            //less than four directpass
            if (size < 4){
    
                System.out.println("No");
                continue;
            }
            boolean flag = false;
            //循环计算
            for (int j = 0; j < size; j++) {
    
                for (int k = j+1; k < size; k++) {
    
                    for (int l = k+1; l < size; l++) {
    
                        for (int m = l+1; m < size; m++) {
    
                            if ((yinShu.get(j) + yinShu.get(k) + yinShu.get(l) + yinShu.get(m))%num == 0){
    
                                flag = true;
                                break;
                            }
                        }
                    }
                }
            }
            System.out.println(flag == true ? "Yes" : "No");
        }
    }
}

结果:
在这里插入图片描述

原网站

版权声明
本文为[dumb bit]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208110645413432.html