UVA - 357Let Me Count The Ways(完全背包)
来源:互联网 发布:知我药妆是不是正品 编辑:程序博客网 时间:2024/05/29 06:29
题目:UVA - 357Let Me Count The Ways(完全背包)
题目大意:给出N,问用1, 5, 10, 25, 50,这些硬币能够凑出N的方式有多少种。
代码:
#include <cstdio>#include <cstring>const int N = 5;const int maxn = 30005;const int coin[N] = {1, 5, 10, 25, 50};typedef long long ll;ll f[maxn];void init () {for(int i = 1; i < maxn; i++)f[i] = 0;f[0] = 1;for (int i = 0; i < N; i++)for (int j = coin[i]; j < maxn; j++) {f[j] += f[j - coin[i]];}}int main () {int n;init();while (scanf ("%d", &n) != EOF) {if (f[n] == 1)printf ("There is only 1 way to produce %d cents change.\n", n);elseprintf ("There are %lld ways to produce %d cents change.\n", f[n], n);}return 0;}
0 0
- UVA - 357Let Me Count The Ways(完全背包)
- UVA - 357 Let Me Count The Ways(完全背包)
- UVA 357Let 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 (DP 完全背包)
- 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
- 【Android】 Android应用程序的启动过程
- 对Class.getResourceAsStream和ClassLoader.getResourceAsStream方法所使用的资源路径的解释
- 目录
- 虚拟机linux和主机时间同步
- Hibernate主键生成策略
- UVA - 357Let Me Count The Ways(完全背包)
- Android 最火快速开发框架AndroidAnnotations使用详解
- Java与C#的比较学习记录
- 二叉树(模板)
- WiFi基本知识(详细)
- 机器学习中的数学(3)-模型组合(Model Combining)之Boosting与Gradient Boosting
- iOS自定义TableViewCell详解[两种步骤]
- 程序员生存定律-打造属于自己的稀缺性
- jdk与jre的区别