hdoj:2069
Coin Change
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 18271 Accepted Submission(s): 6291
For example, if we have 11 cents, then we can make changes with one 10-cent coin and one 1-cent coin, or two 5-cent coins and one 1-cent coin, or one 5-cent coin and six 1-cent coins, or eleven 1-cent coins. So there are four ways of making changes for 11 cents with the above coins. Note that we count that there is one way of making change for zero cent.
Write a program to find the total number of different ways of making changes for any amount of money in cents. Your program should be able to handle up to 100 coins.
26
13
找零钱问题,但是限制了一次找零的硬币数量
下面就直接暴力了
#include <iostream> using namespace std; const int Max = ;
const int a[] = {,,,,};
long dp[Max]; void change()
{
dp[] = ;
for (int m = ; m <= Max; m++)
{
for (int i50 = ; i50 <= m / ; i50++)
{
for (int i25 = ; i25 <= (m - i50 * ) / ; i25++)
{
for (int i10 = ; i10 <= (m - i50 * - i25 * ) / ; i10++)
{
for (int i5 = ; i5 <= (m - i50 * - i25 * - i10 * ) / ; i5++)
{
int i1 = m - i50 * - i25 * - i10 * - i5 * ;
if (i1 >= && i1 + i5 + i10 + i25 + i50 <= )
{
dp[m]++;
}
}
}
}
}
} }
int main()
{
int money;
change();
while (cin >> money)
{
cout << dp[money] << endl;
}
}
hdoj:2069的更多相关文章
- 算法——A*——HDOJ:1813
Escape from Tetris Time Limit: 12000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDOJ:1533-Going Home(最小费用流)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1533 解题心得: 第一次写最小费用流的题,去hdoj上找了一个入门级题目,建图比较简单,用了spfa和 ...
- hdoj:2086
A1 = ? Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- hdoj:2085
核反应堆 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- hdoj:2084
数塔 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...
- hdoj:题目分类
基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058. ...
- HDOJ:6333-Problem B. Harvest of Apples(组合数学+莫队算法+逆元)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6333 解题心得: 这个题可以说是十分精彩了,首先推组合数学的公式,其中一个很重要的公式是Cnm = C ...
- HDOJ:6356-Glad You Came(线段树剪枝)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6356 解题心得: 现在深深的知道了算法复杂度的重要了,这个题算复杂度的时候还要把一些常数也算出来,不然 ...
- hdoj:2075
A|B? Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
随机推荐
- 机器学习系列-tensorflow-01-急切执行API
tensorflow急切执行概述 Eager execution is an imperative, define-by-run interface where operations are exec ...
- MySql基础笔记(二)Mysql语句优化---索引
Mysql语句优化--索引 一.开始优化前的准备 一)explain语句 当MySql要执行一个查询语句的时候,它首先会对语句进行语法检查,然后生成一个QEP(Query Execution Plan ...
- C# virtual、abstract
(1) virtual:修饰的方法必须有实现 abstract:修饰的方法一定不能实现 (2) virtual:可被子类重写, 子类中必须用overide修饰 abstract:必须被子类重写 (3) ...
- C++程序设计方法3:函数重写
派生类对象包含从基类继承类的数据成员,他们构成了“基类子对象”基类中的私有成员,不允许在派生类成员函数中被访问,也不允许派生类的对象访问他们:真正体现基类私有,对派生类也不开放其权限:基类中的公有成员 ...
- es6学习笔记一:迭代器和for-of循环
我们如何遍历一个数组呢?在20年前,我们是这样遍历一个数组的: var myArr = []; for (var i = 0; i < arr.length; i++) { console.lo ...
- 实验楼-Git实战教程
实验1-git介绍 1.版本控制系统: 1)集中式版本控制系统:版本库是集中存放在中央服务器的,工作时需要先从中央服务器取得最新的版本,然后工作完成后把自己的修订推送给中央服务器.这类系统都有一个单一 ...
- 推荐一款jQueryajax插件(Ajaxify jQuery )
推荐一款jQueryajax插件(Ajaxify jQuery ) 此插件相当强悍,但最后一个版本是在2008年,作者很久没更新了,我在寻找了好多关羽ajax的工具,没有发现比这个更灵活的 ...
- golang的dlv调试工具print打印字符串显示more,无法显示更多
使用dlv (delve golang调试器)打印字符串无法打印全,只能打印一部分(64个字节),在gdb中有 (gdb) set print elements Argument required ( ...
- IntelliJ IDEA使用maven-javadoc-plugin生成Java Doc控制台乱码
问题描述 在使用IDEA生成Java Doc的过程中,发现IDEA控制台乱码,作为有轻微代码强迫症的我来说,这是不可忍受的,需要鼓捣一番.先上pom.xml中的javadoc插件配置 <!--配 ...
- js-将一个对象转换成一个新的对象
/** * 对象转换成一个新的对象 * @param object * @private */ function _yh_tranformObject(object){ if(object == nu ...