题目描述
思路
代码
#include <cstdio>
int n, m;
int sz[105];
int ans[105][10005];
int main() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i) scanf("%d", &sz[i]);
for (int i = 0; i <= n; ++i) ans[i][0] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
ans[i][j] = ans[i - 1][j];
if (j >= sz[i]) ans[i][j] += ans[i - 1][j - sz[i]];
}
}
printf("%d\n", ans[n][m]);
return 0;
}