题解 | #跳台阶扩展问题#
跳台阶扩展问题
http://www.nowcoder.com/practice/953b74ca5c4d44bb91f39ac4ddea0fee
#include<iostream>
using namespace std;
int main()
{
int dp[41] = {0},n,sum = 0;
cin >> n;
dp[1] = 1;
dp[2] = 2;
for(int i = 3;i <= n;++i){
for(int j = 1;j < i;++j)
dp[i] += dp[j];
dp[i] += 1;
}
cout << dp[n];
}