han1219 @ 2024-08-12 15:08:51
最后两个点错了。 只得了80pts 代码:
#include<bits/stdc++.h>
using namespace std;
long long s,e,s1,s2,s3,e1,e2,e3,a[13]={0,1,3,1,0,1,0,1,1,0,1,0,1},cnt=0;
int j(int i2,int j2,int k2){
int l=j2*100+k2,r=0;
while(i2){
r=r*10+i2%10;
i2/=10;
}
return r==l;
}
int main(){
cin>>s>>e;
s1=s/10000;
s2=s%10000/100;
s3=s%100;
e1=e/10000;
e2=e%10000/100;
e3=e%100;
int y=s1,m=s2,d=s3;
while(!(y==e1&&m==e2&&d==e3)){
if(j(y,m,d)){
cnt++;
}
d++;
if(a[m]==1&&d>31){
m++;
d=1;
}else if(a[m]==0&&d>30){
m++;
d=1;
}else if(a[m]==3&&(y%400==0||(y%4==0&&y%100!=0))&&d>29){
m++;
d=1;
}else if(a[m]==3&&d>28){
m++;
d=1;
}
if(m>12){
m=1;
y++;
}
}
if(j(e1,e2,e3)){
cnt++;
}
cout<<cnt;
return 0;
}
帮忙给关注
by abc20131113 @ 2024-08-18 17:53:00
这是我写的。我才不告诉你是我看不出来问题,但看似我俩写的思路差不多