首页 > 其他 > 详细

[luoguP1474] 货币系统 Money Systems(背包)

时间:2017-06-20 16:05:33      阅读:228      评论:0      收藏:0      [点我收藏+]

传送门

 

背包

 

——代码

#include <cstdio>
#include <iostream>
#define LL long long

int v, n;
LL f[10001];

inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch == ‘-‘) f = -1;
	for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - ‘0‘;
	return x * f;
}

int main()
{
	int i, j, x;
	v = read();
	n = read();
	f[0] = 1;
	for(i = 1; i <= v; i++)
	{
		x = read();
		for(j = x; j <= n; j++) f[j] += f[j - x];
	}
	printf("%lld\n", f[n]);
	return 0;
} 

  

[luoguP1474] 货币系统 Money Systems(背包)

原文:http://www.cnblogs.com/zhenghaotian/p/7054424.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!