LADDER RIDE
Practice
3.8 (24 votes)
Approved
Math
Medium
Open
Problem
47% Success 7087 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Harit wants to climb ladder having n steps but he want to climb only in step of 2 and 5. Now he felt boring repeating same thing again and again. So he discovered new way, now each time Harit wants to climb in step of k also. In other words he can use steps of 2, 5 or k to climb the ladder. So Harit want to calculate number of different ways to reach at cur step , where k and cur are integers . Although Harit is intelligent yet lazy so he wants your help to calculate number of ways. As number of ways could be too large so he wants you to output it modulo 1000000007 (10^9 + 7) .

Input :
First line consists two space separated integers t and n as number of test cases and total steps in ladder. Each of t lines contains two space separated integers cur and k .

Output :
For each test case output an integer calculated number of ways modulo (10^9 + 7) .

Constraints
1 <= t <= 100000
1 <= n <= 1000000
5 <= k <= 1000000000
cur <= n and sum of all cur such that ( cur >= k ) will not exceed 10000000 .

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
4 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingMediumOpen
Points:30
24 votes
Tags:
AlgorithmsC++CombinatoricsDynamic Programming
Points:30
6 votes
Tags:
AlgorithmsDynamic ProgrammingMediumStacksString Manipulation