Jumping stones
Practice
2.9 (30 votes)
Algorithms
Dynamic programming
Problem
88% Success 8297 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

There are \(n\) stones in a row from left to right. You are standing on the first stone. From every stepĀ from stone number \(i\), you can jump at most \(k\) stones further (\(i + 1,\ i + 2,\ \dots,\ i + k\)). You cannot jump over stone number \(n\). How many ways are there to travel to stone number \(n\)?

Input format

First line: \(n\) and \(k\)

Output format

Print the answer modulo \(10^9+7\).

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
65 votes
Tags:
Ad-HocAlgorithmsApprovedEasyOpen
Points:20
22 votes
Tags:
AlgorithmsDynamic ProgrammingEasy
Points:30
61 votes
Tags:
AlgorithmsApprovedData StructuresGreedy AlgorithmsMediumOpenSorting