Problems > Climbing the Staircase

Climbing the Staircase

Difficulty: 1100 3000 ms 128 MB

dp

You climb a staircase of N steps taking 1 or 2 steps at a time. How many distinct step sequences reach the top, modulo 109+7?

Input: one integer N.

Output: the number of ways mod 109+7.

Constraints:

  • 1 ≤ N ≤ 106

Sample Tests

Input 1
4
Output 1
5
Input 2
1
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.