yunyan_ads @ 2024-10-25 20:12:27
```#include<bits/stdc++.h>
using namespace std;
int sum;
bool hw(int x){
int a[8];
for(int i = 1; i <= 8; i++){
a[i] = x % 10;
x /= 10;
}
int xsum = 0;
for(int i = 1; i <= 4; i++){
if(a[i] == a[8-i+1]) xsum++;
}
if(xsum == 4) return 1;
else return 0;
}
bool ry(int x){
x /= 10000;
if(x % 4 == 0 && x / 100 != 0) return 1;
else if(x % 400 == 0) return 1;
else return 0;
}
int main(){
int sd,ed; cin >> sd >> ed;
for(int i = sd; i <= ed; i++){
int msd = (i % 10000) / 100;
int day = i % 100;
if(hw(i)) sum++;
if(msd == 2){
if(ry(i) && day == 29) i += 100, i -= 29;
if(!ry(i) && day == 28) i += 100, i -= 28;
}
if( (msd == 1 || msd == 3 || msd == 5 || msd == 7 || msd == 8 || msd == 10) && day == 31){
i += 100; i -= 31;
}
if( (msd == 4 || msd == 6 || msd == 9 || msd == 11) && day == 30){
i += 100; i -= 30;
}
if(msd == 12 && day == 31){
i -= 1231; i += 101; i += 10000;
}
}
cout << sum;
return 0;
}
by simple_child @ 2024-10-25 20:14:09
qp @yunyan_ads
by niuniudundun @ 2024-10-28 11:12:39
@yunyan_ads
if(x % 4 == 0 && x / 100 != 0) return 1;
\
改 %
求关
by yunyan_ads @ 2024-10-28 20:04:29
@niuniudundun 已关,感谢