感觉没啥错。。
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n, m, ans = 0;
int mon1[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mon2[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int check1(int x)
{
int a, b, c, d, e;
e = x % 10000;
a = e % 10;
b = e % 100 / 10;
c = e / 100 % 10;
d = e / 1000;
//cout << a << " " << b << " " << c << " " << d << endl;
//cout << x / 10000 << " " << a * 1000 + b * 100 + c * 10 + d << endl;
if (x / 10000 == a * 1000 + b * 100 + c * 10 + d) return true;
else return false;
}
int check2(int x)
{
int nian, f = 0;
nian = x / 10000;
if (nian % 400 == 0 || (nian % 4 == 0 && nian % 100)) f = 1;
int t, h;
t = x % 10000 / 100;
//cout << t << " ";
h = x % 10000 % 100;
//cout << h << " ";
if (f == 1)
{
if (t > 12 || t < 1) return false;
else if (mon1[t] < h) return false;
}
else {
if (t > 12 || t < 1) return false;
else if (mon2[t] < h) return false;
}
return true;
}
signed main()
{
cin >> n >> m;
for (int i = n;i <= m;i += 10000)
{
int k;
k = i / 10000;
int a, b, c, d;
a = k % 10;
b = k % 100 / 10;
c = k / 100 % 10;
d = k / 1000;
int z;
z = k * 10000 + a * 1000 + b * 100 + c * 10 + d;
if (check2(z)) ans ++;
}
cout << ans << endl;
return 0;
}