Interesting Ranges (Small)
Time limit5sMemory limit512 MB
Count subranges of [L, R] containing an even number of decimal palindromes, modulo 1000000007, for R up to 10^13.
- Level
Medium7 of 10
- Topics
- Math, Combinatorics, Binary search, Prefix sum
- Solved
- No attempts yet
Problem
A positive integer is a palindrome if its decimal representation, written without leading zeros, reads the same forwards and backwards. For example, 5, 77, 363, 4884, 11111, 12121 and 349943 are palindromes.
A range of integers is interesting if it contains an even number of palindromes. For , the range is the sequence of integers from to inclusive, that is , and and are its first and last numbers. Zero is even, so a range that contains no palindrome at all is also interesting.
The range is a subrange of if . Determine how many subranges of are interesting.
Input
The first line contains the number of test cases . Each of the next lines describes one test case and contains two positive integers and , in that order, separated by a single space.
Limits
Output
For each test case, print one line in the form Case #x: y, where is the test case number starting from 1 and is the number of interesting subranges of modulo .