QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#10913. AD 2020

الإحصائيات

2020 年是当前年份,也是公历中的一个闰年,它是公元纪年(CE)和主纪年(AD)的第 2020 年,第 3 个千年的第 20 年,21 世纪的第 20 年,以及 2020 年代的第 1 年。

2020 年被世界卫生组织定为“国际护士和助产士年”。联合国宣布 2020 年为“国际植物健康年”。2020 年还被国际声学委员会定为“国际声音年”。

由于 2020 年发生了太多令人难忘的事情,有人提议将所有日期字符串中包含 “202” 的日子定为“减灾日”。我们用 YYYYMMDD 的格式表示日期(例如 21110202),如果 202 是该日期字符串的子串,那么这一天就是“减灾日”。

请编写一个程序,计算在 $Y_1M_1D_1$ 和 $Y_2M_2D_2$ 之间的所有日期(包含起始和结束日期)中,有多少个“减灾日”?请注意,你需要考虑闰年。闰年是指能被 400 整除,或者能被 4 整除但不能被 100 整除的年份。闰年的 2 月有 29 天,而平年的 2 月有 28 天。

输入格式

输入包含多组数据。输入的第一行包含一个正整数 $T$ ($1 \le T \le 10^5$),表示数据组数。

每组数据占一行,包含六个整数 $Y_1, M_1, D_1, Y_2, M_2, D_2$,含义如上所述。

保证 $Y_1M_1D_1$ 不大于 $Y_2M_2D_2$。$Y_1M_1D_1$ 和 $Y_2M_2D_2$ 均在 2000010199991231 之间,且均为合法日期。

我们提醒您,本题的输入输出规模可能较大,建议使用较快的 I/O 方法。例如,在 C++ 中,可以使用 scanf/printf 代替 cin/cout

输出格式

对于每组数据,输出一行,包含一个整数,即答案。

样例

样例输入 1

3
2111 02 01 2111 02 03
2202 01 01 2202 12 31
2000 01 01 9999 12 31

样例输出 1

1
365
44294

说明

在第一个样例中,21110202 是唯一的减灾日。

在第二个样例中,2022202 的子串,因此 2202 年的每一天都是减灾日!

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.