There is a new set of numbers in town called the legal numbers. These numbers hold the following property :
1. 0 is considered neither as even nor as odd.
2. The numbers consist at max two consecutive even or odd digits. (See sample test case for more explanation).
You are to print the sum of the digits of all the legal numbers between l and r.
Constraints:
1 <= T <= 1000
1 <= l <= r <= 1e17
Input format:
The first line contains T, the number of test cases.
T lines follow each containing two integers, denoting l and r.
Output format:
For each test case, output a single integer on a new line denoting the answer to the problem.
2 1 10 200 205
46 27
For the sample case :
Between 1 to 10 all are legal numbers, so answer is 1+2+...+9+(1+0) = 46
Between 200 to 205, all are legal numbers, so answer is (2+0+0)+(2+0+1)+....(2+0+5) = 27
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor