80求助
查看原帖
80求助
972511
Ljh421楼主2024/7/3 09:07
#include<bits/stdc++.h>
//保留小数 fixed << setprecision(3)
using namespace std;
int st,ok,sum; 
int dm[20]={0,31,0,31,30,31,30,31,31,30,31,30,31};
bool hw(int xxx){
	int x[10],a=1;
	for(int i=1;i<=8;i++){
		x[i]=xxx/a%10;
		a*=10;
	}
	for(int i=1;i<=4;i++){
		if(x[i]!=x[9-i]){
			return false;
		}
	}
	return true;
}
int main(){
	
	cin>>st>>ok;
	if(hw(st)){
		sum++;
		//cout<<st<<endl;
	}
	while(st<ok){
		st++;
		int day=st%100,month=st/100%100,year=st/10000;
		if(month==2){
			if((year%4==0&&year&100!=0)||year%400==0){
				dm[2]=29;
			}else{
				dm[2]=28;
			}
		}
		if(day>dm[month]){
			st=st+101-day;
			month++;
		}
		if(month>12){
			st=st+8800;
			year++;
		}
		if(hw(st)){
			sum++;
			//cout<<st<<endl;
		}
	}
	cout<<sum;
	
	return 0;
}
2024/7/3 09:07
加载中...