♻️lzhh_lzhh32 • 2个月前
#include <bits/stdc++.h>
using namespace std;
string from,to;
int date[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int cnt;
bool Is_f(int y,int m,int d){
date[1]=28;
if(y%4==0&&y%400!=0) date[1]=29;
if(m>=1&&m<=12&&d<=date[m-1]) return true;
return false;
}
bool Is_w(int y,int m,int d){
if(d%10!=y/1000) return false;
d/=10;
y%=1000;
if(d%10!=y/100) return false;
d/=10;
y%=100;
if(m%10!=y/10) return false;
m/=10;
y%=10;
if(m!=y) return false;
return true;
}
int main(){
cin>>from>>to;
int yf=1000*int(from[0]-'0')+100*int(from[1]-'0')+10*int(from[2]-'0')+int(from[3]-'0');
int mf=10*int(from[4]-'0')+int(from[5]-'0');
int df=10*int(from[6]-'0')+int(from[7]-'0');
int yt=1000*int(to[0]-'0')+100*int(to[1]-'0')+10*int(to[2]-'0')+int(to[3]-'0');
int mt=10*int(to[4]-'0')+int(to[5]-'0');
int dt=10*int(to[6]-'0')+int(to[7]-'0');
if(yf==yt&&mf==mt&&df==dt&&Is_f(yf,mf,df)&&Is_w(yf,mf,df)){
cout<<1<<endl;
return 0;
}
while(yf!=yt||mf!=mt||df!=dt){
df++;
if(df>date[mf-1]){
df=1;
mf++;
}
if(mf>12){
mf=1;
yf++;
}
if(Is_f(yf,mf,df)&&Is_w(yf,mf,df)) cnt++;
if(yf==yt&&mf==mt&&df==dt) break;
}
cout<<cnt<<endl;
return 0;
}
评论:
请先登录,才能进行评论