60分求助
查看原帖
60分求助
572956
wuhaoran2012楼主2023/9/29 18:32
#include<bits/stdc++.h>
using namespace std;
bool check(long long x){
	string str=to_string(x);
	for(int i=0;i<=3;i++){
		if(str[i]!=str[7-i]) return 0;
	}
	return 1;
}
long long lnm[] {2,4,6,9,11};
long long a,b,ans;
int main(){
	cin>>a>>b;
	for(long long i=a;i<=b;i++){
		long long month=(i/100)%100,day=i%100,year=i/10000;
		if(month>12||day>32) continue;
		bool ok=1;
		for(auto j:lnm){
			if(month==j&&day>30){
				ok=0;break;
			}
		}
		if(!ok) continue;
		if(month==2&&!((year%4==0&&year%100)|(year%400!=0))
		   &&day>28) continue;
		ans+=check(i);
	}
	cout<<ans;
	return 0;
}
2023/9/29 18:32
加载中...