All Tracks Algorithms Dynamic Programming Introduction to Dynamic Programming 1 Problem

Jumping stones
Tag(s):

Algorithms, Dynamic Programming

Problem
Editorial
Analytics

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\).

SAMPLE INPUT
5 2

SAMPLE OUTPUT
5
Explanation

-

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, C++17, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, Java 14, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, Python 3.8, R(RScript), Racket, Ruby, Rust, Scala, Swift-4.1, Swift, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

February Easy '20

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?