#P2010. [NOIP 2016 普及组] 回文日期
[NOIP 2016 普及组] 回文日期
Description
In daily life, a unique date can be specified by the three components: year, month, and day.
Niuniu habitually uses an 8-digit number to represent a date, where the first 4 digits denote the year, the next 2 digits denote the month, and the last 2 digits denote the day. Clearly, a date has only one representation, and two different dates do not share the same representation.
Niuniu considers a date to be palindromic if and only if the 8-digit number representing this date is a palindrome. Now Niuniu wants to know: between the two dates he specifies (including both endpoints), how many real dates are palindromic.
An 8-digit number is palindromic if and only if, for all (), the -th digit from the left is the same as the -th digit (that is, the -th digit from the right).
For example:
- For November 19, 2016, represented by the 8-digit number , it is not palindromic.
- For January 2, 2010, represented by the 8-digit number , it is palindromic.
- For October 2, 2010, represented by the 8-digit number , it is not palindromic.
Each year has 12 months:
Among them, months each have days; months each have days; and for February, there are days in a leap year and days in a common year.
A year is a leap year if and only if it satisfies one of the following:
- The year is a multiple of but not a multiple of ;
- The year is a multiple of .
For example:
- The following years are leap years: .
- The following years are common years: .
Input Format
Two lines, each containing an 8-digit number.
The first line is the start date specified by Niuniu.
The second line is the end date specified by Niuniu.
It is guaranteed that and are real dates, the year part always has 4 digits with a nonzero first digit, and is not later than .
Output Format
Output a single integer, representing how many dates between and (inclusive) are palindromic.
20110101
20111231
1
20000101
20101231
2
Hint
Sample Explanation:
- For sample 1, the valid date is .
- For sample 2, the valid dates are and .
Subtasks:
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号