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 ...
随机推荐
- Codeforces.1110F.Nearest Leaf(线段树)
题目链接 \(dls\)讲过这道题,所以这不是线段树裸题吗,这场没打气气气气气=-= 现在是写着玩=v= \(Description\) 给定一棵\(n\)个点的树.\(q\)次询问,每次询问给定\( ...
- 哈希表(散列表),Hash表漫谈
1.序 该篇分别讲了散列表的引出.散列函数的设计.处理冲突的方法.并给出一段简单的示例代码. 2.散列表的引出 给定一个关键字集合U={0,1......m-1},总共有不大于m个元素.如果m不是很大 ...
- python系统编程(二)
多次fork问题 如果在一个程序,有2次的fork函数调用,是否就会有3个进程呢? #coding=utf-8 import os import time # 注意,fork函数,只在Unix/Lin ...
- jmeter接口测试实例6-注册(参数化)
Jmeter实例6:注册(参数化) 选中http协议,添加CSV Data set Config 准备参数中要使用到的值,存放到txt中,如果一个里面有多个参数,中间用,号分隔: 选中CSV元件,fi ...
- SSD固态硬盘测试工具收集(持续更新)
https://www.crsky.com/zhuanti/gutaiyingpanceshi.html https://www.crsky.com/zhuanti/ssdjiance.html ht ...
- pygame-KidsCanCode系列jumpy-part15-PowerUp加速器
这一节我们给游戏增加点额外的奖励,大多数游戏中都会有金币.装备啥的来激励玩家,在jumpy这个游戏中,我们也可以增加类似的道具:加速器.效果图如下: 档板上会随机出现一些加速器(power up),小 ...
- C# 实现Remoting双向通信
本篇文章主要介绍了C# 实现Remoting双向通信,.Net Remoting 是由客户端通过Remoting,访问通道以获得服务端对象,再通过代理解析为客户端对象来实现通信的 闲来无事想玩玩双向通 ...
- MySQL中exists和in的区别及使用场景
exists和in的使用方式: 1 #对B查询涉及id,使用索引,故B表效率高,可用大表 -->外小内大 1 select * from A where exists (select * fro ...
- webview 向右滑动关闭时,怎么禁止此 webview 上下滚动?
webview 向右滑动关闭时,怎么禁止此 webview 上下滚动?
- MAC 开启与关闭SIP
1. 查看SIP状态 在终端中输入csrutil status,就可以看到是enabled还是disabled. 2. 关闭SIP S1 重启MAC,按住cmd+R直到屏幕上出现苹果的标志和进度条, ...