BronX_xjg @ 2023-01-12 11:10:43
#include<bits/stdc++.h>
using namespace std;
int be,en,t;
bool hw(int a)
{
int s[9];
for(int i=1;i<9;i++)s[i]=a%10,a/=10;
for(int i=1;i<5;i++)if(s[i]!=s[9-i])return 0;
return 1;
}
int main()
{
cin>>be>>en;
for(int i=be;i<=en;i++)
{
int yue=i/100,ri=i%100,nian=i/10000;yue%=100;
if(yue<13&&ri<32)
if(hw(i))
{
if(yue<13&&yue>0&&ri>0&&ri<32)
{
if(yue==1||yue==3||yue==5||yue==7||yue==8||yue==10||yue==12)t++;
else if((yue==4||yue==6||yue==9||yue==11)&&ri<31)t++;
else if(yue==2&&ri<29&&nian%4==0&&(nian%100!=0||nian%400==0))t++;
else if(yue==2&&ri<28&&nian%4!=0)t++;
}
}
}
cout<<t;
}
麻烦看看
by 编码落寞 @ 2023-01-12 13:02:58
@xjgbxbx
ri<29
ri<28
应该是30和29吧
by BronX_xjg @ 2023-01-12 16:56:54
谢谢 AC了