洛谷 P1474 货币系统 Money Systems

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;
}
posted @ 2019-05-10 20:23  Mystery_Sky  阅读(244)  评论(0编辑  收藏  举报