- 回文日期(date)
题解二
- 2023-7-11 11:16:04 @
#include<iostream>
#include<cstdio>
#include<cassert>
using namespace std;
int d1, d2;
int ans;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int getY(int m, int d)
{
return m % 10 * 10 + m / 10 + (d % 10 * 10 + d / 10) * 100;
}
void handle()
{
// 枚举 月和日
for(int m = 1; m <= 12; m++)
{
int y;
for(int d = 1; d <= days[m]; d++)
{
y = getY(m, d);
int c = y * 10000 + m * 100 + d;
if(d1 <= c && c <= d2)
{
ans++;
}
}
}
if(d1 <= 92200229 && 92200229 <= d2)
ans++;
cout << ans << endl;
}
int main(void)
{
cin >> d1 >> d2;
handle();
return 0;
}
0 条评论
目前还没有评论...
信息
- ID
- 183
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 267
- 已通过
- 64
- 上传者