UVa 357 - Let Me Count The Ways
2013-06-13 11:17
471 查看
/* 注意要用long long */ #include <cstring> #include <cstdio> #include <algorithm> #include <iostream> #include <iomanip> using namespace std; const int MAXN = 30005; int coins[] = {1, 5, 10, 25, 50}; int type = sizeof(coins) / sizeof(coins[0]); long long d[MAXN]; void dp() { d[0] = 1; for(int i=0; i<type; i++) { for(int j=1; j<=30000; j++) if(j >= coins[i]){ d[j] += d[j-coins[i]]; } } } int main(){ #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif dp(); int n; while(scanf("%d", &n)==1) { if(d == 1) { printf("There is only 1 way to produce %d cents change.\n", n); } else { printf("There are %lld ways to produce %d cents change.\n", d , n); } } }
相关文章推荐
- 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
- 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
- uva 357 Let Me Count The Ways