401934: GYM100589 B Count Palindromes
Description
Given two times when seen on a digital clock, count the number of moments between these two times (both start and end time included) when the time was a palindrome.
A digital clock shows time in the format HH:MM:SS (hours:minutes:seconds).
For example, 2:40:38 pm is represented as 14:40:38.
InputThe first line contains q ( ≤ 105) queries. This is followed by q lines each containing two time strings, t1 and t2, which are 6 digit integers that represent times shown by a digital clock. It is ensured that t1 and t2 are valid times(t1 occurs on or before t2).
OutputFor each query in one line print the number of palindromic times.
ExamplesInput4Output
00:00:01 00:00:01
09:09:09 13:34:57
11:11:11 11:11:11
02:38:15 03:01:16
0Note
22
1
3
Query 1: Only 1 moment is considered in this case, i.e., 00:00:01. We can clearly see that 00:00:01 is not a palindromic string.
Query 4: Between 02:38:15 and 03:01:16, there are 3 moments that are palindromic strings. They are 02:44:20, 02:55:20 and 03:00:30.
Note that the time as seen on a digital clock should appear as a palindrome. 1 is a palindrome, but 00:00:01 on a digital clock is not.