当前位置:网站首页>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");
}
}
}
结果:
边栏推荐
猜你喜欢

Douyin share password url API tool

When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields

【推荐系统】:协同过滤和基于内容过滤概述

【Pytorch】nn.Linear,nn.Conv

Daily sql-seek the sum of successful investments in 2016

易观分析联合中小银行联盟发布海南数字经济指数,敬请期待!

数仓开发知识总结

Get Pinduoduo product information operation details

TF中的One-hot

tf中自减操作;tf.assign_sub()
随机推荐
unable to extend table xxx by 1024 in tablespace xxxx
LeetCode刷题系列 -- 46. 全排列
【预约观看】Ambire 智能钱包 AMA 活动第四期即将举行
年薪40W测试工程师成长之路,你在哪个阶段?
Amazon API interface Daquan
Taobao API interface reference
prometheus学习5altermanager
docker安装mysql5.7(仅供测试使用)
js根据当天获取前几天的日期
Unity底层是如何处理C#的
软件测试主要做什么工作,难不难?
ROS 话题通信理论模型
MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段
go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...
Internet phone software or consolidation of attack must be "free" calls security clearance
Do not add the is prefix to the variables of the boolean type in the POJO class of the Alibaba specification
Service的两种启动方式与区别
Unity程序员如何提升自己的能力
计算YUV文件的PSNR与SSIM
sql--Users who have purchased more than 3 times (inclusive) within 7 days (including the current day), and the purchase amount in the past 7 days exceeds 1,000