题解
2023-05-27 17:25:41
发布于:上海
44阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e8+5;
int n,m;
int yearm[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int year1,year2,mony1,mony2,day1,day2;
int ans;
void run(int x){
if(x%4==0&&x%100!=0||x%400==0){
yearm[2]=29;
}else{
yearm[2]=28;
}
}
void day(int p,int q,int x,int y){
for(int i=x;i<=y;i++){
int sum=p*10000+q*100+i;
int cnt=0;
int o=sum;
while(o){
cnt*=10;
cnt+=o%10;
o/=10;
}
if(cnt==sum) ans++;
}
}
void mony(int t,int x,int y){
for(int i=x;i<=y;i++){
if(t==year1&&i==x){
day(t,i,day1,yearm[i]);
}else if(t==year2&&i==y){
day(t,i,1,day2);
}else{
day(t,i,1,yearm[i]);
}
}
}
int main(){
cin>>n>>m;
day1=n%100;
n/=100;
mony1=n%100;
n/=100;
year1=n;
day2=m%100;
m/=100;
mony2=m%100;
m/=100;
year2=m;
ans=0;
for(int i=year1;i<=year2;i++){
run(i);
if(i==year1){
if(year2==i){
mony(i,mony1,mony2);
} else{
mony(i,mony1,12);
}
}else if(i==year2){
mony(i,1,mony2);
}else{
mony(i,1,12);
}
}
cout<<ans<<endl;
return 0;
}
这里空空如也
有帮助,赞一个