Embercode
✕
Dynamic ProgrammingCoding problems

Dynamic Programming: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 7 solved

  • A climber faces a staircase with n steps. Each move climbs one step or two steps. Count the different ways to reach the top, where two ways are different if the sequence of moves differs. Use a table of ways for each number of steps, and remember that the count can be large, so use long.

    Input. One line with one integer `n`, where 1 <= n <= 45.

    Output. One integer: the number of ways to climb exactly `n` steps.

    Example 1 input

    5
    

    Output

    8
    

    Example 2 input

    1
    

    Output

    1