wangmuze @ 2024-10-22 17:12:01
C++ Code
#include<bits/stdc++.h>
using namespace std;
bool pal(unsigned long long x)
{
string s1=to_string(x);
string s2=s1;
reverse(s2.begin(),s2.end());
return s1==s2;
}
unsigned long long day[14]={0,31,0,31,30,31,30,31,31,30,31,30,31};
bool truetime(unsigned long long x)
{
unsigned long long y=x/10000;
unsigned long long m=(x-10000*y)/100;
unsigned long long d=x-y*10000-m*100;
if(m*100+d==229)
{
return true;
}
if(d>day[m])
{
return false;
}
else
{
return true;
}
}
int main()
{
unsigned long long start;
cin>>start;
unsigned long long end;
cin>>end;
unsigned long long cnt=0;
for(unsigned long long i=start;i<=end;i++)
{
if(pal(i)&&truetime(i))
{
cnt++;
}
}
cout<<cnt<<endl;
return 0;
}