Files
python/TangDou/AcWing/BeiBao/278_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

22 lines
445 B
C++
Raw 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 = 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;
}