题解 | #跳台阶#
跳台阶
https://www.nowcoder.com/practice/bfb2a2b3cdbd4bd6bba0d4dca69aa3f0
#include <iostream> using namespace std; const int N = 41; int dp[N]; int main() { int n; cin >> n; dp[0] = 0; dp[1] = 1; dp[2] = 2; for(int i = 3;i <= n;i++) { dp[i] = dp[i-1] + dp[i-2]; } cout << dp[n] << endl; return 0; }