uva_357 Let Me Count The Ways
2012-10-30 18:15
435 查看
#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 ) { 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); } } return 0; }
相关文章推荐
- uva 357 Let Me Count The Ways(01背包)
- UVA - 357 Let Me Count The Ways
- UVa 357 Let Me Count The Ways (完全背包)
- UVA 357 - Let Me Count The Ways(母函数)
- UVa 357 - Let Me Count The Ways
- UVA 357 Let Me Count The Ways(全然背包)
- UVa 357 - Let Me Count The Ways 背包
- UVA - 357 Let Me Count The Ways
- UVA - 357 Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- uva 357 - Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- UVA 357 - Let Me Count The Ways
- UVA 357 Let me count the ways
- uva357 Let Me Count The Ways
- UVA 357 Let Me Count The Ways 动态规划解法、母函数解法
- UVa 357 Let Me Count The Ways
- UVA 357 Let Me Count The Ways (dp + 完全背包)
- UVa 357 - Let Me Count The Ways