_Ayanami_Rei_ @ 2022-10-24 11:36:34
#include <iostream>
using namespace std;
bool cmp(int f, int e) {
int a = f / 1000;
int b = e % 10;
if (a != b) {
return false;
}
f %= 1000;
e /= 10;
a = f / 100;
b = e % 10;
if (a != b) {
return false;
}
f %= 100;
e /= 10;
a = f / 10;
b = e % 10;
if (a != b) {
return false;
}
f %= 10;
e /= 10;
if (f != e) {
return false;
}
return true;
}
int main() {
int date1;
int date2;
cin >> date1 >> date2;
int ans = 0;
for (int date = date1;date <= date2;) {
int f = date / 10000;
int e = date % 10000;
if (cmp(f, e)) ++ans;
int month = date/100%100;
int day = date % 100;
int year = date / 10000;
++day;
switch (month) {
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
case 1:{
if (day > 31) {
day = 1;
++month;
if (month > 12) {
month = 1;
++year;
}
}
break;
}
case 2:{
if ((year % 100 == 0 && year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) {
if (day > 29) {
++month;
day = 1;
break;
}
}
if (day > 28) {
++month;
day = 1;
}
break;
}
case 4:
case 6:
case 9:
case 11:{
if (day > 30) {
day = 1;
++month;
}
break;
}
}
date = year * 10000 + month * 100 + day;
}
cout << ans;
return 0;
}