80分?
查看原帖
80分?
777965
c_y_y楼主2023/9/24 19:18
#include<bits/stdc++.h>
using namespace std;
int data[]={0,31,0,31,30,31,30,31,31,30,31,30,31};
bool check(int y,int m,int d){
	return y/1000==d%10 && y/100%10==d/10 && y/10%10==m%10 && y%10==m/10;
}
bool checky(int year){
	return !year%4 && year%100 || !year%400;
}
int main() {
	cin.tie(0),cout.tie(0),ios::sync_with_stdio(false);
	int date1,date2;
	cin>>date1>>date2;
	int y=date1/10000,m=date1/100%100,d=date1%100;
	int ey=date2/10000,em=date2/100%100,ed=date2%100;
	int ans=0;
	while(y!=ey || m!=em || d!=ed){
		if(check(y,m,d)) ans++;
		d++;
		if(m!=2 && d>data[m] || m==2 && !checky(y) && d>28 || m==2 && checky(y) && d>29){
			d=1;
			m++;
			if(m>12) m=1,y++;
		}
	}
	cout<<ans+check(ey,em,ed);
	return 0;
}

2023/9/24 19:18
加载中...