1. 程式人生 > 其它 >A - AD 2020(字首和,空間壓縮,模擬,3維陣列)

A - AD 2020(字首和,空間壓縮,模擬,3維陣列)

2020 is the current year and is a leap year starting on Wednesday of the Gregorian calendar, the 2020th year of the Common Era (CE) and Anno Domini (AD) designations, the 20th year of the 3rd millennium, the 20th year of the 21st century, and the 1st year of the 2020s decade.

2020 has been designated as Year of the Nurse and Midwife by the World Health Organization. The United Nations has declared 2020
as the International Year of Plant Health. 2020 has been designated as International Year of Sound by the International Commission for Acoustics. Because there are so many unforgettable things happening in 2020, somebody has now proposed that all dates with a substring containing "202" to be designated as
the Day for Disaster Reduction. We represent a date in the format YYYYMMDD (for example, 21110202), then if 202 is a substring of this date, this day is the Day for Disaster Reduction. Please write a program to compute how many Days for Disaster Reduction are there in all the dates between Y_1Y 1 ​ M_1M
1 ​ D_1D 1 ​ and Y_2Y 2 ​ M_2M 2 ​ D_2D 2 ​ (both inclusive)? Note that you should take leap years into consideration. A leap year is a year that can be divided by 400 or can be divided by 4 but can't be divided by 100. A leap year has 2929 days in February, instead of the normal 2828 days. Input The input contains multiple cases. The first line of the input contains a single positive integer TT (1 \le T \le 10^51≤T≤10 5 ), the number of cases. The first and only line of each case contains six integers Y_1,M_1,D_1,Y_2,M_2,D_2Y 1 ​ ,M 1 ​ ,D 1 ​ ,Y 2 ​ ,M 2 ​ ,D 2 ​ , which are described in the problem statement above. It's guaranteed that Y_1Y 1 ​ M_1M 1 ​ D_1D 1is not larger than Y_2Y 2 ​ M_2M 2 ​ D_2D 2 ​ . Both Y_1Y 1 ​ M_1M 1 ​ D_1D 1 ​ and Y_2Y 2 ​ M_2M 2 ​ D_2D 2 ​ are between 20000101 and 99991231, and both dates are valid. We kindly remind you that the size of the input and output of this problem can be large, so it's recommended to use a faster I/O method. For example, in C++, you can use scanf/printf instead of cin/cout. Output For each case, print a single line containing a single integer, the answer. Sample 1 Inputcopy Outputcopy 3 2111 02 01 2111 02 03 2202 01 01 2202 12 31 2000 01 01 9999 12 31 1 365 44294 Note In the first sample case, 21110202 is the only Day for Disaster Reduction. In the second sample case, 202 is a substring of 2202, so every day in the year 2202 is the Day for Disaster Reduction!
View Problem