#P13447. [GCJ 2009 #3] Interesting Ranges

[GCJ 2009 #3] Interesting Ranges

题目描述

A positive integer is a palindrome if its decimal representation (without leading zeros) is a palindromic string (a string that reads the same forwards and backwards). For example, the numbers 55, 7777, 363363, 48844884, 1111111111, 1212112121 and 349943349943 are palindromes.

A range of integers is interesting if it contains an even number of palindromes. The range [L,R][L, R], with LRL \leqslant R, is defined as the sequence of integers from LL to RR (inclusive): (L,L+1,L+2,,R1,R)(L, L+1, L+2, \ldots, R-1, R). LL and RR are the range's first and last numbers.

The range [L1,R1][L_1, R_1] is a subrange of [L,R][L, R] if LL1R1RL \leqslant L_1 \leqslant R_1 \leqslant R. Your job is to determine how many interesting subranges of [L,R][L, R] there are.

输入格式

The first line of input gives the number of test cases, TT. TT test cases follow. Each test case is a single line containing two positive integers, LL and RR (in that order), separated by a space.

输出格式

For each test case, output one line. That line should contain "Case #x: y", where xx is the case number starting with 11, and yy is the number of interesting subranges of [L,R][L, R], modulo 10000000071000000007.

3
1 2
1 7
12 110
Case #1: 1
Case #2: 12
Case #3: 2466

提示

Limits

  • 1T1201 \leqslant T \leqslant 120

Small dataset(9 Pts)

  • 1LR10131 \leqslant L \leqslant R \leqslant 10^{13}

Large dataset(23 Pts)

  • 1LR101001 \leqslant L \leqslant R \leqslant 10^{100}