Jumping stones

2.9

30 votes
Algorithms, Dynamic Programming
Problem

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, , 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 109+7.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

-

Editor Image

?