题目链接: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;
}