Traditional Array
Practice
3.9 (8 votes)
Algorithms
Approved
Dynamic programming
Medium
Two dimensional
Problem
72% Success 1119 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Panda is preparing for a family get together. She decided to enjoy some traditions of her family. To impress everyone she decides to show her skills in the meeting.

A traditional array is an array in which all the adjacent elements are happy. Adjacent elements are happy if and only if one of them divides the other one. More formally, if Ai divides Ai+1 or Ai+1 divides Ai, then these are happy elements. All elements of the array should be integers in range [1, M].

Find out the number of traditional arrays of given length N. As the output can be very large, find answer modulo 109+7.

Input:
First line contains a single integer T, number of testcases.
Each test case has 2 elements N, length of array and M, the range of elements.

Output:
Single line for the answer of each testcase.

Constraints:
1 ≤ T ≤ 10
1 ≤ N,M ≤ 1000

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
9 votes
Tags:
Dynamic ProgrammingAlgorithms2D dynamic programmingData Structures
Points:30
6 votes
Tags:
Ad-HocAlgorithmsApprovedDynamic ProgrammingMediumOpenTwo dimensional
Points:30
2 votes
Tags:
AlgorithmsDynamic Programming2D dynamic programming