jcjkyx110507 @ 2023-12-26 17:15:39
#include<bits/stdc++.h>
using namespace std;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int palindrome(int aa){
int ss=0;
while(aa){
ss=ss*10+aa%10;
aa/=10;
}
return ss;
}
bool isRn(int year){
return (year%4==0&&year%100!=0)||year%400==0;
}
int main(){
int a,b,ans=0;
cin>>a>>b;
for(int i=a;i<=b;++i){
int x=i/10000,y=i/100%100,z=i%100;
if(isRn(x)) month[2]=29;
else month[2]=28;
if(palindrome(i)==i){
if(((y<=12)&&(y>0))&&((z<=month[y])&&(z>0)))
ans++;
}
}
cout<<ans;
return 0;
}
by run_away @ 2023-12-26 17:26:06
你这个一天一天枚举肯定要tle啊