You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
650 B

This file contains ambiguous Unicode characters!

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;
typedef long long LL;
const int N = 30;
const int M = 1e4 + 10;
LL f[N][M];
int w[N];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
f[0][0] = 1; // 使用0种货币凑0元钱,也是一种方案。可以理解为是超级源点,有了它,每个基础货币价格才成为合法~
for (int i = 1; i <= n; i++)
for (int j = 0; j <= m; j++) {
for (int k = 0; k * w[i] <= j; k++)
f[i][j] += f[i - 1][j - k * w[i]];
}
printf("%lld\n", f[n][m]);
return 0;
}