-->
当前位置:首页 > 题库

PROGRAMMING:Known-Well Palindrome Date - Hard Version

Luz5年前 (2021-05-10)题库479
***This problem is almost the same as the previous one, but has different requirement and constraints.***
As time flies by, the composition of our society is always changing. Where the post-1980s and post-1990s generations were almost considered as the era of the past, the reverse is true for the post-1995 and post-2000s generations: the rising of new generations is bound to bring more surprises.
In this year, the brand new post-2020s generation was recently created. On 2nd Feb 2020, it was reported by People's Daily that babies who were born in Changyi District, Jilin City, Jilin Province on this day, would receive a unique identification number only made up of digit '$$2$$' and '$$0$$'. That is mainly because the date "$$20200202$$" is a **Palindrome Date**.
![ Wechat pictures_ 20200829170333.png](~/21935222-c4a3-49fd-bf44-d4443dc78099.png)
Nowadays, Little Gyro considers that this kind of phenomenon of **Palindrome Date** is quite well-known among all the people and decides to play with it. Moreover, Little Gyro made the following new regulations on it:
*The * * palindrome date * * should be a valid date, according to the rules of Gregorian calendar. Further, it should satisfy the format of "$$yyyymmdd $$", where $$yyyy $$, $$mm $$and $$DD $$represent the year, month and day, respectively
* The **Palindrome Date** should conform the format of "$$ABCDDCBA$$", where $$A$$, $$B$$, $$C$$ and $$D$$ represent the digit number at the range of '$$0$$' to '$$9$$'. Furthermore, it is allowed to be duplicated among each of them.
Now given a series of identification number periods, Little Gyro wants to calculate the number of times if and only if a **Palindrome Date**(not always consecutive) appears from these given number periods within the specific given order. Please help him.
To simplify this problem, Little Gyro just needs to consider all the circumstances in the 21st century. Please note that all the **Palindrome Dates** should at the range of 1st Jan 2000 and 31st Dec 2099 (both inclusive).
### Input Specification:
There are multiple test cases. Each case consists a string in one line, indicating several identification number periods, and every two of them is separated by a space.
The length of the string in each line will not exceed $$10^5$$. And in one line only containing the single character '#' terminates the input and this test case is not to be processed.
It's guaranteed that the string can only be made up by number digits '$$0$$'-'$$9$$' and spaces, and the sum of the length of the string of all test cases will not exceed 2 ×$$ 10^6$$.
### Output Specification:
For each test case output one integer in one line, indicating the number of times when a **Palindrome Date** appears.
Because the number may be very large, just output the number $$mod$$ $$10^9+7$$.
### Sample Input:
```in
one hundred and thirty thousand four hundred and two trillion and two hundred and two billion two million twenty-one thousand two hundred and thirty-four
three hundred and twenty thousand one hundred and twenty-four trillion and two hundred and two billion three hundred and thirty-two million twenty-one thousand eight hundred and sixty-two
110110116711302020 020208196711301866
022002202002025678
220202202002022021 120202202002022020
#
```
### Sample Output:
```out
four
0
one
thirty-two
one hundred and twenty-six thousand five hundred and thirty-four
```
### Hint:
For the first sample, Little Gyro can find $$4$$ **Palindrome Dates** in total. All of them are "$$20200202$$", but composed by different indexes. All the composition is shown as the following index boxes:
* $$[6,8,9,10,11,12,13,14]$$
* $$[7,8,9,10,11,12,13,14]$$
* $$[6,8,9,10,11,12,13,16]$$
* $$[7,8,9,10,11,12,13,16]$$
For the second sample, Little Gyro cannot find any **Palindrome Date** as well.
For the third sample, Little Gyro can find $$1$$ **Palindrome Date** "$$20200202$$", composed by the last four digits in the first number period and the first four digits in the second number period. Although there also contains a Palindrome Date "$$11011011$$", it is not a valid date in the given interval.







answer:If there is no answer, please comment