Her_Lingxiao @ 2020-07-30 15:02:37
本地+洛谷IDE是对的,但是每次交的时候都不给对
#include <cstdio>
using namespace std;
const int SRC[13] = {29/*闰年*/, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
int begin, end;
int b, e;
int year = 0, lj = 0, fan = 0;
int month, day;
long long ans = 0;
scanf("%d\n%d", &begin, &end);
b = begin, e = end;
year = (b / (int)1e8) * 10000 + ((b / (int)1e7 ) % 10) * 1000 + ((b / (int)1e6) % 10) * 100 + ((b / (int)1e5) % 10) * 10 + ((b / (int)1e4) % 10);
lj = (e / (int)1e8) * 10000 + (e / (int)1e7 % 10) * 1000 + (e / (int)1e6 % 10) * 100 + (e / (int)1e5 % 10) * 10 + (e / (int)1e4 % 10);
month = (e / (int)1e3 % 10) * 10 + ((e / (int)1e2) % 10);
day = ((e / 10) % 10) * 10 + (e % 10);
#if 0
printf("month = %d\tday = %d\n", month, day);
#endif
for(int i = year; i <= lj; i++)
{
int m, d;
fan = (i / 1000) + ((i / 100) % 10) * 10 + ((i / 10) % 10) * 100 + (i % 10) * 1000;
m = fan / 100;
d = (fan - (fan / 100) * 100) / 10 * 10 + (fan % 10);
if(m == 0 || m > 12)
continue;
if(((i % 4 == 0 && i % 100) || !(i % 400)) && m == 2)
m = 0;
if(m <= 12 && m >= 0 && d <= SRC[m] && d > 0 && m <= month)
{
// if(i < lj || (i == lj && m <= month && d <= day))
ans++;
}
#if 0
printf("%d \tm = %d\td = %d\tmonth = %d\n", fan, m, d, month);
#endif
}
printf("%lld", ans);
return 0;
}