tj

黄戈  •  1年前


#include<bits/stdc++.h>
using namespace std; 
int date[]={0,31,0,31,30,31,30,31,31,30,31,30,31};
bool huiwen(int x){
	if(x/10000000==x%10&&x/1000000%10==x/10%10&&x/100000%10==x/100%10&&x/10000%10==x/1000%10){
		return true;
	}
	return false;
} 
bool kongzhi(int x){
	if(x/100%100==2){
		int year=x/10000;
		if(year%400==0 || (year%100!=0 && year%4==0)){
			if(x%100<=29){
				return true;
			}
			return false;
		}
		else{
			if(x%100<=28){
				return true;
			}
			return false;
		}
	}
	if(x%100<=date[x/100%100]){
		return true;
	}
	return false;
}
long long cnt;
int main() {
	int a,b;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(kongzhi(i)==0){
			if(i/100%100==12){
				i+=10000;
				i-=1231;
				i+=101;
			}
			else{
				i/=100;
				i*=100;
				i++;
				i+=100;
			}
		}
		if(huiwen(i)){
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}
//防复制,有一个错误的地方


评论: