Files
python/TangDou/AcWing/BeiBao/278_2.cpp

22 lines
445 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
int n, m;
int v;
int f[N]; // 在前i个物品,体积是j的情况下,恰好装满的方案数
int main() {
cin >> n >> m;
// 体积恰好j, f[0]=1, 其余是0
f[0] = 1;
for (int i = 1; i <= n; i++) {
cin >> v;
for (int j = m; j >= v; j--)
f[j] += f[j - v];
}
printf("%d\n", f[m]);
return 0;
}