feat(DP): new dp problems formated

This commit is contained in:
2025-11-04 21:14:50 -03:00
parent 669c13147b
commit 3b03c32703
925 changed files with 30660 additions and 0 deletions

25
flowers/src/ac.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
int N, M; cin >> N >> M;
vector<vector<ll>> dp(N + 1, vector<ll>(2, 0));
// DP[i][j] := Number of configurations where:
// i := length of the arrangement of flowers (first i flowers placed)
// j := 0 or 1 (represents the type of the last flower placed)
dp[0][0] = dp[0][1] = 1;
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= 1; j++) {
int opposite = (int)(!j);
for (int k = 1; k <= M && i + k <= N; k++) {
dp[i + k][opposite] += dp[i][j];
}
}
}
cout << dp[N][0] + dp[N][1] << endl;
return 0;
}