4. Climbing Stairs
EasyDynamic ProgrammingRecursion
You are climbing a staircase with n steps. Each time you can climb 1 or 2 steps. In how many distinct ways can you reach the top?
Input format
A single integer n.
Output format
The number of distinct ways.
Example 1
Input
2
Output
2
Explanation: 1+1 or 2.
Example 2
Input
3
Output
3
Explanation: 1+1+1, 1+2 or 2+1.
Constraints
1 ≤ n ≤ 80
Read input from standard input and print the answer to standard output. Your code is judged against 7 test cases, most of them hidden.
Loading the MyLoginn IDE…