当前位置:网站首页>1096 大美数 (15 分)
1096 大美数 (15 分)
2022-08-11 06:45:00 【呆比特】
题目要求:
代码:
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<>();
//找出所有不相同的因数
for (int j = 1; j <= num; j++) {
if (num%j == 0 && !yinShu.contains(j)){
yinShu.add(j);
}
}
int size = yinShu.size();
//少于四个直接pass
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");
}
}
}
结果:
边栏推荐
猜你喜欢

2022年中国软饮料市场洞察

MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段

年薪40W测试工程师成长之路,你在哪个阶段?

unable to extend table xxx by 1024 in tablespace xxxx

Strongly recommend an easy-to-use API interface

基于FPGA的FIR滤波器的实现(4)— 串行结构FIR滤波器的FPGA代码实现

Pinduoduo api interface application example

Daily sql-seek the sum of successful investments in 2016

prometheus学习5altermanager

Daily sql-employee bonus filtering and answer rate ranking first
随机推荐
【LeetCode每日一题】——682.棒球比赛
Tidb二进制集群搭建
Trill keyword search goods - API
Redis测试
jar服务导致cpu飙升问题-带解决方法
linux 安装mysql服务报错
Multiscale communication in cortical-cortical networks
Douyin share password url API tool
tf中自减操作;tf.assign_sub()
pytorch,numpy两种方法实现nms类间+类内
Unity底层是如何处理C#的
Service的两种启动方式与区别
Pinduoduo API interface (attach my available API)
国密规范 SM2 SM3 SM4
Pinduoduo api interface application example
【软件测试】(北京)字节跳动科技有限公司终面HR面试题
How Unity handles C# under the hood
接口测试的基础流程和用例设计方法你知道吗?
js根据当天获取前几天的日期
Production and optimization of Unity game leaderboards