Digital Numbers
Practice
3.6 (7 votes)
Mathematics
Dynamic programming
Easy Medium
Problem
30% Success 2242 Attempts 30 Points 4s Time Limit 256MB Memory 1024 KB Max Code

Bosky is a very curious child who turned 13 yesterday. His parents gifted him a digital watch which he really liked. He was amazed to see how each number can be represented inside one cell only by switching different edges on and off.

Today, while he was in his home alone, getting bored looking at his watch, an idea popped up in his scientific mind. He immediately went to the garage and picked up a long rectangular cardboard, which was 2 units wide and L units long, and lots of thin LED tubes which were 1 unit long.

Bosky wanted to place LED tubes on the rectangular cardboard in such a way that he can represent as many digits as possible using the LED tubes and rectangular board similar to how digits are represented on his watch.

LED Numbers

He realized that none of the LED tubes are working so he decided to purchase new LED tubes.

Each LED tube will cost Rs. 7

He has Rs. M with him and he now goes to market and spends all the money purchasing LED tubes.

After he brought all the LED tubes home, he wondered how many different digits he can represent on the rectangular board such that he doesn't have to repeat a number again.

But Bosky is tired now and does not want to try all the possible combinations to figure out how many digits he can represent on the board. He knows that you are a great programmer and you would surely help him. He calls you and tells you the length L and the amount of money M he has. Now, you have to tell him how many different digits he can represent on the rectangular board such that none of the digits is repeated, given:

0 requires -- 6 tubes

1 requires -- 2 tubes

2 requires -- 5 tubes

3 requires -- 5 tubes

4 requires -- 4 tubes

5 requires -- 5 tubes

6 requires -- 6 tubes

7 requires -- 3 tubes

8 requires -- 7 tubes

9 requires -- 6 tubes

[NOTE: Each digit occupies exactly 1 unit length on the board]

Input:

Input will contain a number T denoting the number of test cases.

Then T test cases follow, each one consisting of two space-separated integers L and M .

Output

For each test case, output a single integer - the number of different digits Bosky can represent on the rectangular board such that none of the number is repeated and all the digits fit on the board.

Constraints

1 <= T <= 100

0 <= M <= 2000

0 <= L <= 10

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:20
37 votes
Tags:
AlgorithmsApprovedBacktrackingDepth First SearchEasyGraphsOpenRecursion
Points:20
6 votes
Tags:
Basic ProgrammingOpenApprovedEasyMathamatics
Points:20
95 votes
Tags:
EasyImplementation
Editorial

No editorial available for this problem.