Legal Numbers

0

0 votes
Medium
Problem

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.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

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

 

 

Editor Image

?