0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:48:48 +00:00

P1077 [NOIP2012 普及组] 摆花

R72644809
This commit is contained in:
Baoshuo Ren 2022-03-28 21:23:42 +08:00
parent 771b935a33
commit ed7e55aea1
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

37
Luogu/P1077/P1077.cpp Normal file
View File

@ -0,0 +1,37 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105,
mod = 1e6 + 7;
int n, m, a[N], f[N][N];
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 0; i <= n; i++) {
f[i][0] = 1;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= a[i]; j++) {
for (int k = 0; k <= m - j; k++) {
if (j || k) {
f[i][j + k] = (f[i][j + k] + f[i - 1][k]) % mod;
}
}
}
}
cout << f[n][m] % mod << endl;
return 0;
}