SOLVE

LATER

You get your Christmas gift!

Problem

Editorial

Analytics

You pick all the gifts and Santa gives you a christmas gift.You unpack your gift wrapper and finds a a small rubber ball . This ball is particularly bouncy, which makes it great fun for throwing down a flight of stairs of your house.

On each bounce, the ball may jump over one step or it may jump over several steps. The ball never loses momentum, so each bounce must jump over at least as many steps as the previous bounce. In the illustration below, the left hand diagram shows a valid passage down eight steps, whereas the right hand diagram shows an invalid passage down eight steps.

The path of the ball down the flight of stairs can be represented as a sequence of positive integers, with each integer representing the number of steps that are jumped over on a single bounce. Thus the left hand diagram above can be represented by the sequence 1, 2, 2, 3, and the right hand diagram above can be represented by the sequence 3, 2, 3.

Note that the final bounce must be exactly the right length to reach the bottom of the staircase. For example, for a staircase of eight steps, the sequence 3, 4, 5 is invalid since the final bounce covers more steps than are available. The sequence 3, 4, 1 is also invalid since, even though it covers the correct amount of steps, the final bounce is smaller than the bounce before it.

Some balls are in fact so bouncy that they accelerate as they make their way down the stairs. If a ball has acceleration a, each bounce must jump over at least a more steps than the previous bounce. For example, if a ball with acceleration 2 makes its way down a flight of 11 stairs, it may follow the path 1, 4, 6 but it may not follow the path 2, 3, 6. Both of these paths are illustrated below.

Your task is to write a program that, given the acceleration of the ball a and the length of the flight of stairs n, returns the number of valid paths the ball can take to cover the flight.

Explanation

For n = 10 and a = 1, the output should be 10.

Here are all possible valid paths the ball can take:

**Input/Output**

[time limit] 3000ms [input] integer n

The length of the flight of stairs.

**Constraints:**
1 ≤ n ≤ 120.

**[input]** integer a

Acceleration of the ball.

**Constraints:**
0 ≤ a ≤ n.

**[output]** integer

The number of paths the ball can take to jump down the flight.

Time Limit:
3.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:
C,
C++,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala 2.11.8,
Swift,
Visual Basic

Initializing Code Editor...

{"52ef942": "/pagelets/suggested-problems/algorithm/you-get-your-christmas-gift/", "52ef910": "/pagelets/show-submission/algorithm/you-get-your-christmas-gift/", "52ef971": "/pagelets/problems-hint/algorithm/you-get-your-christmas-gift/", "52ef986": "/pagelets/recommended-problems/algorithm/you-get-your-christmas-gift/", "52ef95b": "/pagelets/problem-author-tester/algorithm/you-get-your-christmas-gift/"}

{}

realtime.hackerearth.com

80

a7ca48a2e5889efcc2ac2b59333b5f8b5063721d

58a29e5cae2309f04b28

/realtime/pusher/auth/