#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define COIN 5
#define MAXN 30000+10
unsigned long long dp[MAXN];
int coin[] = {1, 5, 10, 25, 50};
void complete_knapsack(void)
{
memset(dp, 0, sizeof(dp)); dp[0] = 1;
for(int i = 0; i < COIN; i ++) {
for(int j = 1; j < MAXN; j ++) {
if( j < coin[i] ) {
continue;
}
dp[j] += dp[j-coin[i]];
}
}
}
int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
freopen("test.in", "r", stdin);
#endif
int n;
complete_knapsack();
while( ~scanf("%d", &n) ) {
if( 1 == dp[n] ) {
printf("There is only 1 way to produce %d cents change.\n", n);
}
else {
printf("There are %llu ways to produce %d cents change.\n", dp[n], n);
}
}
return 0;
}
uva_357 Let Me Count The Ways
最新推荐文章于 2016-03-13 23:25:20 发布