P2010 [NOIP2016 普及组] 回文日期
#include<bits/stdc++.h>
using namespace std;
int ret;
string s,t,cnt;
int md[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool year(int n){
if(n%100!=0&&n%400==0){
return true;
}if(n%4==0){
return true;
}return false;
}bool hw(string s){
int len=s.size();
for(int i=0;i<=len/2;i++){
if(s[i]!=s[len-i-1]){
return false;
}
}
}void change(){
int y=(cnt[0]-'0')*1000+(cnt[1]-'0')*100+(cnt[2]-'0')*10+(cnt[3]-'0'),m=(cnt[4]-'0')*10+(cnt[5]-'0'),d=(cnt[6]-'0')*10+(cnt[7]-'0');
if(year(y)){
md[2]=29;
}if(d==md[m]){
cnt[6]='0',cnt[7]='1';
d=1;
if(m==12){
m=1;
cnt[4]='0',cnt[5]='1';
y++;
int now=3;
while(cnt[now]=='9'){
cnt[now]='0';
now--;
}cnt[now]++;
}else{
if(cnt[5]=='9'){
cnt[5]='0';
cnt[4]++;
}else{
cnt[5]++;
}
}
}else{
if(cnt[7]=='9'){
cnt[7]='0';
cnt[6]++;
}else{
cnt[7]++;
}
}if(year(y)){
md[2]=28;
}
}int main(){
cin>>s>>t;
cnt=s;
while(cnt!=t){
if(hw(cnt)){
ret++;
}change();
}printf("%d",ret);
return 0;
}