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

25 lines
523 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 = 110;
int n, m;
int f[N][N];//第一维:前i个物品,第二维:体积j及以下
int main() {
cin >> n >> m;
//初始化
for (int i = 0; i <= m; i++) f[0][i] = 1;
for (int i = 1; i <= n; i++) {
int v;
cin >> v;
for (int j = 0; j <= m; j++) {
f[i][j] = f[i - 1][j];
if (j >= v) f[i][j] += f[i - 1][j - v];
}
}
cout << f[n][m] << endl;
return 0;
}