这道题主要要注意一下每个月的天数不同,主要考查了对截取数字的某一段的应用,废话不多说,上代码:
#include <bits/stdc++.h>
using namespace std;
int day[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
// 分别记录每个月的天数
int c, ans, sum;
int main() {
freopen("date.in", "r", stdin);
freopen("date.out", "w", stdout);
int n, m;
cin >> n >> m;
for (int i = 1; i <= 12; i++) {//枚举一下月和日
for (int j = 1; j <= day[i]; j++) {
c = (j % 10) * 1000 + (j / 10) * 100 + (i % 10) * 10 + (i / 10);
sum = c * 10000 + i * 100 + j;
if (sum < n or sum > m) {
continue;
}
ans++;
}
}
cout << ans << endl;
return 0;
}
管理员大大给过一下呗,拜托🙏