标签:http io for 数据 ar 代码 amp line size
题目大意:给出11种硬币,然后给出一个数字,问可以有多少方式由上面的给的硬币凑出。这里要注意精度误差,题目可能会给出20.005这样的数据,虽然我觉得这是不合法的数据,但是但是会给,并且还需要你向上取整。
解题思路:完全背包。
代码:
#include <cstdio>
#include <cstring>
const int N = 11;
const int maxn = 30005;
const int c[N] = {5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000};
typedef long long ll;
ll f[maxn];
void  init () {
	memset (f, 0, sizeof (f));
	f[0] = 1;
	for (int i = 0; i < N; i++)
		for (int j = c[i]; j <= maxn - 5; j++)
			f[j] += f[j - c[i]];
}
int main () {
	
	init();
	float num;
	int n;
	while (1) {
		scanf ("%f", &num);
		n = (num + 0.005) * 100;
		if (!n)
			break;
		printf ("%6.2f%17lld\n", num, f[n]);
	}
	return 0;
}标签:http io for 数据 ar 代码 amp line size
原文地址:http://blog.csdn.net/u012997373/article/details/38781543