闰年判断:y % 4 == 0 && y % 100 || y % 400 == 0
#include<iostream>
using namespace std;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int check(int date){
int p = 1e7, q = 10;
while(p >= q){
int a = date / p % 10, b = date % q / (q / 10);
if(a != b) return 0;
p /= 10, q *= 10;
}
return 1;
}
int main(){
int date1, date2;
cin >> date1 >> date2;
int y = date1 / 10000, m = date1 % 10000 / 100, d = date1 % 100;
int res = 0;
while(date1 <= date2){
if(check(date1)) res ++;
d ++;
int t = days[m];
if(m == 2 && (y % 4 == 0 && y % 100 || y % 400 == 0)) t ++;
if(d > t) d = 1, m ++;
if(m > 12) m = 1, y ++;
date1 = y * 10000 + m * 100 + d;
}
cout << res;
return 0;
}