UVA.357 Let Me Count The Ways (DP 完全背包)
来源:互联网 发布:压力 知乎 编辑:程序博客网 时间:2024/05/15 03:37
UVA.357 Let Me Count The Ways (DP 完全背包)
题意分析
与UVA.UVA.674 Coin Change是一模一样的题。需要注意的是,此题的数据量较大,dp数组需要使用long long 类型;另外输出方案为1个和多个的时候,语句是不同的。
代码总览
/* Title:UVA.357 Author:pengwill Date:2017-2-16*/#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#define nmax 30005#define ll long longusing namespace std;ll dp[nmax];int m[5] = {1,5,10,25,50};int main(){ dp[0] = 1; for(int i = 0; i<5 ;++i){ for(int j= 0;j+m[i]<nmax;++j){ dp[j+m[i]] += dp[j]; } } int n; while(scanf("%d",&n)!= EOF){ if(dp[n] == 1) printf("There is only %lld way to produce %d cents change.\n",dp[n],n); else printf("There are %lld ways to produce %d cents change.\n",dp[n],n); } return 0;}
0 0
- UVA 357Let Me Count The Ways (dp + 完全背包)
- UVA.357 Let Me Count The Ways (DP 完全背包)
- UVa 357 Let Me Count The Ways (完全背包)
- UVA 357 Let Me Count The Ways 完全背包
- UVA - 357Let 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(01背包)
- uva 357 Let Me Count The Ways 简单dp
- Let Me Count The Ways - UVa 357 dp
- uva 357 Let Me Count The Ways (DP)
- 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.10066 The Twin Towers (DP LCS)
- 如何在平凡的工作中提升自己的SEO营销优化力?
- UVA.10130 SuperSale (DP 01背包)
- 121. Best Time to Buy and Sell Stock
- UVA.10192 Vacation (DP LCS)
- UVA.357 Let Me Count The Ways (DP 完全背包)
- 122. Best Time to Buy and Sell Stock II
- ubuntu 搭建 hadoop环境
- 123. Best Time to Buy and Sell Stock III
- 124. Binary Tree Maximum Path Sum
- 125. Valid Palindrome
- 使用Socket,让连接客户端可以对服务端执行相应的指令
- 《java语言程序设计》第三章学习总结
- 多渠道打包---友盟统计(下载量、Bug....)