Files
python/GESP/Level6/20240301_dp1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

47 lines
798 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int MOD = 1e9 + 7;
int n, a, b, c;
int f[N];
int ans;
int main() {
#ifndef ONLINE_JUDGE
freopen("20240301.in", "r", stdin);
#endif
/**
例1
1 1 1 1
答案1
例2
114 51 4 1
答案176
例3
114514 191 9 810
答案384178446
*/
// 从大向小推
cin >> n >> a >> b >> c;
f[n] = 1;
for (int i = n; i > c; i--) {
if (i - a >= 0)
f[i - a] = (f[i - a] + f[i]) % MOD;
else
f[0] = (f[i] + f[0]) % MOD;
if (i - b >= 0)
f[i - b] = (f[i - b] + f[i]) % MOD;
else
f[0] = (f[0] + f[i]) % MOD;
}
for (int i = 0; i <= c; i++)
ans = (ans + f[i]) % MOD;
printf("%d\n", ans);
return 0;
}