```#include <iostream>
#include <algorithm>
#include <vector>
bool isLeap(int y) {
return (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0);
}
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
string op , ed; cin >> op >> ed;
string op_year , op_month , op_day , ed_year , ed_month , ed_day;
op_year = op.substr(0 , 4); op_month = op.substr(4,2); op_day = op.substr(6,2);
ed_year = ed.substr(0 , 4); ed_month = ed.substr(4,2); ed_day = ed.substr(6,2);
int b_y = stoi(op_year) , b_m = stoi(op_month) , b_d = stoi(op_day);
int e_y = stoi(ed_year) , e_m = stoi(ed_month) , e_d = stoi(ed_day);
int cur_y = b_y;
int res = 0 ;
while(cur_y <= e_y ){
string cur = to_string(cur_y);
string R_cur = cur;
reverse(R_cur.begin() , R_cur.end());
string R_m = R_cur.substr(0,2);
string R_d = R_cur.substr(2,2);
int R_month = stoi(R_m);
int R_day = stoi(R_d);
if(R_month > 12 ||(R_month == 2 && R_day > 29 && isLeap(cur_y)) || (R_month == 2 && R_day > 28 && !isLeap(cur_y)) ||
((R_month == 1 || R_month == 3 || R_month == 5 || R_month == 7 || R_month == 8 || R_month == 10 || R_month == 12) && R_day > 31) ||
((R_month == 4 || R_month == 6 || R_month == 9 || R_month == 11) && R_day > 30)||
(R_month == 0) || (R_day == 0)
){
cur_y ++;
continue ;
}
res ++;
cur_y ++;
}
cout << res << endl;
return 0;
}
我的臭虫代码喵呜呜,hia ~TT ,我的想法把遍历年份翻转检验月和日的合法性,存在的话res++