c_y_y @ 2023-09-24 19:18:07
#include<bits/stdc++.h>
using namespace std;
int data[]={0,31,0,31,30,31,30,31,31,30,31,30,31};
bool check(int y,int m,int d){
return y/1000==d%10 && y/100%10==d/10 && y/10%10==m%10 && y%10==m/10;
}
bool checky(int year){
return !year%4 && year%100 || !year%400;
}
int main() {
cin.tie(0),cout.tie(0),ios::sync_with_stdio(false);
int date1,date2;
cin>>date1>>date2;
int y=date1/10000,m=date1/100%100,d=date1%100;
int ey=date2/10000,em=date2/100%100,ed=date2%100;
int ans=0;
while(y!=ey || m!=em || d!=ed){
if(check(y,m,d)) ans++;
d++;
if(m!=2 && d>data[m] || m==2 && !checky(y) && d>28 || m==2 && checky(y) && d>29){
d=1;
m++;
if(m>12) m=1,y++;
}
}
cout<<ans+check(ey,em,ed);
return 0;
}
by danzai10 @ 2023-10-05 21:13:55
#include<bits/stdc++.h>
using namespace std;
int month[15]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int x,y,sum;
int main(){
cin>>x>>y;
for(int i=1;i<=12;i++){
for(int j=1;j<=month[i];j++){
int k=j%10*1000+(j/10)*100+(i%10)*10+(i/10);
k=k*10000+i*100+j;
if(k>=x&&k<=y){
sum++;
}
}
}
cout<<sum;
return 0;
}