joey007 @ 2023-01-03 09:49:24
我也想当神犇,可惜只能做个骉犇逼了。。。
#include <iostream>
using namespace std;
bool leap(int year){
if(year % 4 == 0 && year % 100 != 0){
return true;
}
else if(year % 400 == 0){
return true;
}
return false;
}
bool palindromic(int date){
int palinded_date = 0,date_b = date;
while(date_b > 0){
palinded_date = palinded_date * 10 + date_b % 10;
date_b /= 10;
}
if(palinded_date == date){
return true;
}
return false;
}
int palinded(int date){
int date_2 = date,palin = 0;
while(date_2 > 0){
palin = palin * 10 + date_2 % 10;
date_2 /= 10;
}
return palin;
}
int main(){
int date1,date2,sum = 0;
cin>>date1>>date2;
date1 /= 10000;
date2 /= 10000;
for(date1;date1 <= date2;date1++){
int palindate = palinded(date1);
if(palindate / 100 > 12 || palindate / 100 < 1){
continue;
}
else if(palindate == 1 && palindate == 3 && palindate == 5 && palindate == 7 && palindate == 8 && palindate == 10 && palindate == 12){
if(palindate % 100 > 31 || palindate % 100 < 1){
continue;
}
}
else if(palindate == 4 && palindate == 6 && palindate == 9 && palindate == 11){
if(palindate % 100 > 30 || palindate % 100 < 1){
continue;
}
}
else if(palindate == 2){
if(leap(date1)){
if(palindate % 100 > 29 || palindate % 100 < 1){
continue;
}
}
else{
if(palindate % 100 > 28 || palindate % 100 < 1){
continue;
}
}
}
int date_no2 = date1;
date_no2 = date_no2 * 10000 + palindate;
if(palindromic(date_no2)){
sum++;
}
}
cout<<sum;
return 0;
}
救命。。。