You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
573 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 110, mod = 1000007;
int n, m;
int f[N][N]; // f[i, j] 表示前i个物品总体积是j的方案数
int main() {
cin >> n >> m;
f[0][0] = 1; // 求方案数的base case
for (int i = 1; i <= n; i++) {
int a;
cin >> a; // 最多允许选a个
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= min(a, j); k++)
f[i][j] = (f[i][j] + f[i - 1][j - k]) % mod;
}
}
cout << f[n][m] << endl;
return 0;
}