您的位置:首页 > 其它

Uva 147 Dollars 完全背包

2013-04-16 19:23 363 查看
题目链接:here

题意:和uva674差不多。。11种金币,输出能组成给定数额的方法个数

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 30010/5;
int coin[11] = {1,2,4,10,20,40,100,200,400,1000,2000};
long long  dp[maxn];

int main()
{
	int i, j;
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for (i=0; i<11; i++)
	{
		for (j=coin[i]; j<=maxn; j++)
		{
			if (j >= coin[i])
				dp[j] += dp[j-coin[i]];
		}
	}
	double n;
	while (scanf("%lf", &n) != EOF)
	{
		int tmp = (int)(20*n+0.5);
		if (tmp == 0) break;
		printf("%6.2lf%17lld\n", n, dp[tmp]);
	}
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: