我是歌者 @ 2024-07-14 15:18:48
#include<bits/stdc++.h>
using namespace std;
int n,m;
bool d(int x){
int temp=x;
int num=0;
while(x){
num = num*10+x%10;
x=x/10;
}
if(temp==num) return true;
else return false;
}
int n1,n2,n3,n4,n5,n6,n7,n8,nian,yue,ri,ans;
int main(){
cin>>n>>m;
for(int i=n;i<=m;i++){
int a=i;
n8=a%10;
a/=10;
n7=a%10;
a/=10;
n6=a%10;
a/=10;
n5=a%10;
a/=10;
n4=a%10;
a/=10;
n3=a%10;
a/=10;
n2=a%10;
a/=10;
n1=a%10;
a/=10;
nian=n1*1000+n2*100+n3*10+n4;
yue=n5*10+n6;
ri=n7*10+n8;
if(ri>31 || yue>12){
continue;
}
if(yue==4||yue==6||yue==9||yue==11){
if(ri>=31) continue;
}
if((nian%4==0&&nian%100!=0)||nian%400==0){
if(yue==2){
if(ri>29){
continue;
}
}
}
else{
if(yue==2){
if(ri>28) continue;
}
}
if(d(i)){
ans++;
}
}
cout<<ans;
return 0;
}
4个WA
by candy0014 @ 2024-07-14 15:35:24
@我是歌者 月和日为
by 我是歌者 @ 2024-07-14 15:58:55
@candy0014 谢谢谢谢