fgjghfh

Microsoft  •  9个月前


include<bits/stdc++.h>

pragma GCC optimize(3)

using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; int st,en,ans; int Build(int x) {

int y=x;
while(x)
{
	y*=10;
	y+=x%10;
	x/=10;
}
return y;

} bool Check(int x) {

int year=x/10000,month=x/100%100,date=x%100;
if(date>=32 || date<=0)return 0;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
	if(date>31)return 0;
}
else if(month==4||month==6||month==9||month==11)
{
	if(date>30)return 0;
}
else if(month==2)
{
	if(year%400==0 || (year%100!=0 && year%4==0))
    {
	    if(date>=30)
		{
			return 0;
		}
	}
	else
	{
		if(date>=29)
		{
				return 0;
		}
	}
}
else
{
	return 0;
}
return 1;

} int main() {

cin>>st>>en;
for(int i=1000;i<=9999;++i)
{
	int k=Build(i);
	if(Check(k) && k>=st && k<=en)
	{
		//cout<<k<<endl;
		ans++;
	}
}
cout<<ans;
return 0;

}


评论: