
ZOJ Problem Set  4044
Consider representing a date in the format YMMDD, where Y is the year without leading zeros, MM is the twodigit month, and DD is the twodigit day of the month. For example, 20180610, which means June 10th, year 2018; Or even 1234560610, which means June 10th, year 123456. Your task is to calculate the number of palindromes in all the dates between Y_{1}M_{1}M_{1}D_{1}D_{1} and Y_{2}M_{2}M_{2}D_{2}D_{2} (both inclusive). To simplify this problem, you don't need to take leap years into consideration. That is to say, in this problem, February in every year always has only 28 days. A palindrome is a string that can be read the same way from left to right and from right to left. For example, '92400429' and '212131212' are both palindromes. InputThere are multiple test cases. The first line of the input is an integer $T$ ($1 \le T \le 10^4$), indicating the number of test cases. For each test case: The first and only line contains two dates Y_{1}M_{1}M_{1}D_{1}D_{1} and Y_{2}M_{2}M_{2}D_{2}D_{2} ($2000 \le Y_1, Y_2 < 10^{18}$), their meanings are described above. It's guaranteed that the first date is not larger than the second date, and both dates are valid. OutputFor each test case, you should output one line containing one integer, indicating the answer of this test case. Sample Input4 9240000429 9240990429 92200228 92200301 20180610 1234560610 1234567890101 9876543211231 Sample Output10 0 3884 300000 HintFor the first sample test case, the 10 palindromic dates are: 9240000429, 9240110429, 9240220429, ..., 9240990429. For the second sample test case, note that in this problem, we don't take leap years into consideration. So 92200229 is not a valid date and is thus ignored. Author: WENG, Caizhi Source: ZOJ Monthly, June 2018 