This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int M = 10010;
int a[N], f[N][M];
int n, m;
int main() {
cin >> n >> m;
for (int i = 1; i <= n; ++i)cin >> a[i];
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j) {
//正好相等,方案数+1
if (j == a[i])f[i][j] = f[i - 1][j] + 1;
//如果大于,不选,就是原来的方案数;选了,那么就依赖于j-a[i]这些钱在i-1个物品中的方案数
if (j > a[i]) f[i][j] = f[i - 1][j] + f[i - 1][j - a[i]];
//如果小于,没的选择
if (j < a[i]) f[i][j] = f[i - 1][j];
}
cout << f[n][m];
return 0;