21 lines
418 B
C++
21 lines
418 B
C++
#include <bits/stdc++.h>
|
||
|
||
using namespace std;
|
||
const int N = 110;
|
||
int n, m;
|
||
int f[N];
|
||
|
||
int main() {
|
||
cin >> n >> m;
|
||
f[0] = 1;
|
||
for (int i = 1; i <= n; i++) {
|
||
int v;
|
||
cin >> v;
|
||
for (int j = m; j >= 0; j--)//即使物品体积比j大,j - v < 0,也能选,等价于f[0]
|
||
f[j] = f[j] + f[max(0, j - v)];
|
||
}
|
||
cout << f[m] << endl;
|
||
return 0;
|
||
}
|
||
|