Legal Numbers
Practice
0 (0 votes)
Medium
Problem
15% Success 305 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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.

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
15 votes
Tags:
Applications of Dynamic ProgrammingAlgorithmsDynamic ProgrammingDynamic programming
Points:30
5 votes
Tags:
AlgorithmsMediumDynamic ProgrammingDynamic programming