P1474 货币系统 Money Systems

!! 不是noip2018的那道题。

简单的多重背包的变式。

#include <iostream>
#include <cstdio>
using namespace std;
//Mystery_Sky
//
#define ll long long
#define M 10000
int v, m;
ll c[M], f[M];
int main() {
    scanf("%d%d", &m, &v);
    for(int i = 1; i <= m; i++) scanf("%lld", &c[i]);
    f[0] = 1;
    for(int i = 1; i <= m; i++)
        for(int j = c[i]; j <= v; j++)
            f[j] += f[j-c[i]];
    printf("%lld\n", f[v]);
    return 0;
}
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄