Answer the question
In order to leave comments, you need to log in
How can I fix my code for solving the "Bunny" problem?
There is such a dynamic programming problem.
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main() {
int k, n;
cin >> k >> n;
vector<int> dp(n + 2, 0);
dp[0] = 0;
dp[1] = 1;
for (int i = 0; i <= n + 1; i++) {
for (int j = 1; j <= k; j++) {
if (i - j >= 0)
dp[i] += dp[i - j];
}
}
cout << dp[n+1] << endl;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question