网站 建设的售后服务,关键词排名优化技巧,网站站长,工厂外发订单哪里去找问题描述 小蓝现在有一个长度为 100 的数组#xff0c;数组中的每个元素的值都在 0 到 9 的范围之内。数组中的元素从左至右如下所示#xff1a; 5 6 8 6 9 1 6 1 2 4 9 1 9 8 2 3 6 4 7 7 5 9 5 0 3 8 7 5 8 1 5 8 6 1 8 3 0 3 7 9 2 7 0 5 8 8 5 7 0 9 9 1 9 4 4 6 8 6 …问题描述 小蓝现在有一个长度为 100 的数组数组中的每个元素的值都在 0 到 9 的范围之内。数组中的元素从左至右如下所示 5 6 8 6 9 1 6 1 2 4 9 1 9 8 2 3 6 4 7 7 5 9 5 0 3 8 7 5 8 1 5 8 6 1 8 3 0 3 7 9 2 7 0 5 8 8 5 7 0 9 9 1 9 4 4 6 8 6 3 3 8 5 1 6 3 4 6 7 0 7 8 2 7 6 8 9 5 6 5 6 1 4 0 1 0 0 9 4 8 0 9 1 2 8 5 0 2 5 3 3现在他想要从这个数组中寻找一些满足以下条件的子序列 1.子序列的长度为 8
2.这个子序列可以按照下标顺序组成一个 yyyymmdd 格式的日期并且要求这个日期是 2023 年中的某一天的日期例如 20230902 20231223。 yyyy 表示年份 mm 表示月份dd 表示天数当月份或者天数的长度只有一位时需要一个前导零补充。
请你帮小蓝计算下按上述条件一共能找到多少个不同的 2023 年的日期。对于相同的日期你只需要统计一次即可。
答案提交
这是一道结果填空的题你只需要算出结果后提交即可。本题的结果为一个整数在提交答案时只填写这个整数填写多余的内容将无法得分。
import java.util.*;
import java.math.*;
public class Main{public static void main(String[] args) {Scanner scan new Scanner(System.in);int[] anew int[100];for(int i0;i100;i){a[i]scan.nextInt();}HashSetInteger setnew HashSet();for(int a10;a199;a1) {for(int a2a11;a299;a2) {for(int a3a21;a399;a3) {for(int a4a31;a499;a4) {int yeara[a1]*1000a[a2]*100a[a3]*10a[a4];if(year2023) {for(int a5a41;a599;a5) {for(int a6a51;a699;a6) {int montha[a5]*10a[a6];if(month1month12) {for(int a7a61;a799;a7) {for(int a8a71;a899;a8) {int daya[a7]*10a[a8];if(day1day31) {if(check(year,month,day)) {int num(year*100month)*100day;set.add(num);}}}}}}}}}}}}System.out.println(set.size());scan.close();}public static boolean check(int year,int month,int day){if(month2day28){return true;}if(month1||month3||month5||month7||month8||month10||month12){if(day1day31){return true;}else{return false;}}if(month4||month6||month9||month11){if(day1day30){return true;}else{return false;}}return false;}
}