写鼠我了
主要记得闰年是
可以被四或四百整除, 但是不能被100
整除的年份
import java.util.*;
public class Main {
static int[] month = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
public static int getcnt(int x, int y, int z)
{
int cnt = 0;
for (int i = 1; i < x; i ++ )
{
cnt += 356;
if (i % 4 == 0 && i % 100 != 0) cnt ++;
}
for (int i = 1; i < y; i ++ )
cnt += month[i];
cnt += z;
return cnt;
}
public static boolean get(int a, int b, int c)
{
int t = 0;
if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0) t ++;
if (a < 1960 || a > 2059 || b > 12) return false;
if (b == 2 && c > month[b] + t || b != 2 && c > month[b] || c == 0 || b == 0) return false;
return getcnt(a, b, c) >= getcnt(1960, 1, 1) && getcnt(a, b, c) <= getcnt(2059, 12, 31);
}
public static void check(int x, int y, int z)
{
if (get(1900 + x, y, z))
{
System.out.print((1900 + x) + "-");
if (y >= 10) System.out.print(y + "-");
else System.out.print("0" + y + "-");
if (z >= 10) System.out.println(z);
else System.out.println("0" + z);
}
if (get(2000 + x, y, z))
{
System.out.print((2000 + x) + "-");
if (y >= 10) System.out.print(y + "-");
else System.out.print("0" + y + "-");
if (z >= 10) System.out.println(z);
else System.out.println("0" + z);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String ch = sc.next();
int a, b, c;
a = (ch.charAt(0) - '0') * 10 + ch.charAt(1) - '0';
b = (ch.charAt(3) - '0') * 10 + ch.charAt(4) - '0';
c = (ch.charAt(6) - '0') * 10 + ch.charAt(7) - '0';
if (a < c)
{
check(a, b, c);
if (a < b)
{
check(c, a, b);
check(c, b, a);
}
else if (a == b) check(c, a, b);
else
{
check(c, b, a);
check(c, a, b);
}
}
else if (a == c)
{
if (a < b)
{
check(c, a, b);
check(a, b, c);
}
else if (a == b) check(a, b, c);
else
{
check(a, b, c);
check(c, a, b);
}
}
else
{
if (a > b)
{
check(c, b, a);
check(c, a, b);
check(a, b, c);
}
else if (a == b)
{
check(c, b, a);
check(a, b, c);
}
else
{
check(c, a, b);
check(c, b, a);
check(a, b, c);
}
}
}
}