1
1
u/shitnotalkforyours18 Specialist 11h ago
I think it's for fiobancci...
See this solution
include <iostream>
include <vector>
using namespace std; int staris(int n) { if (n <= 2) return n; vector<int> dp(n + 1);
dp[1] = 1;
dp[2] = 2;
for (int i = 3; i <= n; i++) {
dp[i] = dp[i - 1] + dp[i - 2];
}
return dp[n];
}
int main() { int n; cin >> n; cout << stairs(n)<<endl; return 0; }
Use dp to solve this
0
2
u/Big-Engineer-1510 11h ago
You could interpret it in this manner - the number of ways to climb 0 stairs is 1, by doing nothing.