#P16776. [GKS 2020 #H] Boring Numbers

[GKS 2020 #H] Boring Numbers

Problem Description

Ron read a book about boring numbers. According to the book, a positive number is called boring if all of the digits at even positions in the number are even and all of the digits at odd positions are odd. The digits are enumerated from left to right starting from 11. For example, the number 14781478 is boring as the odd positions include the digits {1,7}\{1, 7\} which are odd and even positions include the digits {4,8}\{4, 8\} which are even.

Given two numbers LL and RR, Ron wants to count how many numbers in the range [L,R][L, R] (LL and RR inclusive) are boring. Ron is unable to solve the problem, hence he needs your help.

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case consists of a single line with two numbers LL and RR.

Output Format

For each test case, output one line containing Case #xx: yy, where xx is the test case number (starting from 11) and yy is the count of boring numbers.

3
5 15
120 125
779 783
Case #1: 6
Case #2: 3
Case #3: 2

Hint

In Sample Case 11, the numbers in the range are {5,6,7,8,9,10,11,12,13,14,15}\{5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\} out of which {5,7,9,10,12,14}\{5, 7, 9, 10, 12, 14\} are boring, hence the answer is 66.

In Sample Case 22, the numbers in the range are {120,121,122,123,124,125}\{120, 121, 122, 123, 124, 125\} out of which {121,123,125}\{121, 123, 125\} are boring, hence the answer is 33.

In Sample Case 33, the numbers in the range are {779,780,781,782,783}\{779, 780, 781, 782, 783\} out of which {781,783}\{781, 783\} are boring, hence the answer is 22.

Limits

1T1001 \le T \le 100.

Test Set 11

1LR1031 \le L \le R \le 10^3.

Test Set 22

1LR10181 \le L \le R \le 10^{18}.