82分求助
查看原帖
82分求助
121813
老子是北瓜楼主2020/9/13 16:55
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int month[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int a[100];
bool is_rev(int x){
	int tmp=x,i=0;
	for(int i=1; i<=8; ++i){
		a[i]=tmp%10;
		tmp/=10;
	}
	for(int i=1; i<=8; ++i)
		if(a[i]!=a[8-i+1]) return 0;
	return 1;
}
bool is_year(int x){
	if(x%400==0) return 1;
	if(x%4==0 && x%100!=0) return 1;
	return 0;
}
int main(){
	int date1,date2,s=0;
	cin>>date1>>date2;
	int y,m,d;
	y=date1/10000;
	m=date1/100%100;
	d=date1%100;
	while(y*10000+m*100+d!=date2){
		s+=is_rev(y*10000+m*100+d);
		if(d==month[m]+is_year(y))
		{
			if(m==12){
				m=1;
				++y;
				d=1;
			}
			else{
				++m;
				d=1;
			}
		}
		else
			++d;
	}
	s+=is_rev(date2);
	cout<<s;
	return 0;
}
2020/9/13 16:55
加载中...