题目
public class Main {public static boolean isLegal(String date) {int l = 0;int n = date.length();while(l<=(n-3)) {int t1 = (int)Integer.valueOf(date.substring(l,l+1));int t2 = (int)Integer.valueOf(date.substring(l+1,l+2));int t3 = (int)Integer.valueOf(date.substring(l+2,l+3));if(t1 == t2-1 && t2 == t3-1) {return true;}l++;}return false;}public static void main(String[] args) {int res = 0;int[] days = new int[] {31,28,31,30,31,30,31,31,30,31,30,31};StringBuffer date = new StringBuffer("2022");for(int m=1;m<=12;m++) {if(m<10) {date.append(0);}date.append(m);for(int d=1;d<=days[m-1];d++) {if(d<10) {date.append(0);}date.append(d);if(isLegal(date.toString())) {res++;}date.delete(6, 8);}date.delete(4, 8);}System.out.println(res);}
}