HDU2069 Coin Change(暴力)
来源:互联网 发布:不配说爱我网络 编辑:程序博客网 时间:2024/06/05 09:01
Coin Change
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18240 Accepted Submission(s): 6279
Problem Description
Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.
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.
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.
Input
The input file contains any number of lines, each one consisting of a number ( ≤250 ) for the amount of money in cents.
Output
For each input line, output a line containing the number of different ways of making changes with the above 5 types of coins.
Sample Input
1126
Sample Output
413
Author
Lily
Source
浙江工业大学网络选拔赛
http://acm.split.hdu.edu.cn/showproblem.php?pid=2069
此题最坑的地方是没讲换成的硬币数量不能超过100
原题 https://www.bnuoj.com/v3/problem_show.php?pid=17813 是没要求100的 数据量也不一样 方法也不一样
给你这么多钱让你换 有五种(50,25,10,5,1)有多少种方法 1 5 和 5 1算一种
这题有太多的方法了 母函数(解决排列组合问题) dp背包 记忆化搜索
我这里要讲的是暴力 给的是250 明显让你暴力(优化一下)
还有的仁兄直接暴力打表 太可怕了 用搜索打表
#include<bits/stdc++.h>using namespace std;int main(){ int n,i,j,k,u,sum; while(scanf("%d",&n)!=EOF) { sum=0; for(i=0; i<=n/50; i++) { int g1=n-i*50; for(j=0; j<=g1/25; j++) { int g2=g1-j*25; for(k=0; k<=g2/10; k++) { int g3=g2-k*10; for(u=0; u<=g3/5; u++) { int g4=g3-u*5; if(i+j+k+u+g4<=100) sum++; } } } } printf("%d\n",sum); } return 0;}
0 0
- HDU2069 Coin Change 【暴力】
- HDU2069 Coin Change(暴力)
- HDU2069 Coin Change,背包
- HDU2069 Coin Change 背包
- HDU2069 Coin Change
- HDU2069 Coin Change (DP)
- 【HDU2069】【Coin Change】
- hdu2069 Coin Change
- Coin Change(hdu2069,暴力or母函数)
- 【背包/母函数】HDU2069-Coin Change
- Coin Change(暴力枚举)
- 【母函数】hdu2069(Coin Change)母函数加深
- HDU 2069 Coin Change (暴力)
- 【HDU】2069 - Coin Change(暴力)
- 【HDU 2069】Coin Change 暴力枚举法
- HDU2069 Coin change HDU 1114 Piggy-Bank HDU1712 ACboy needs your help
- HDU2069 & UVA 674 Coin Change(换硬币 dp 入门经典水题,背包问题)
- hdu2069 暴力打表
- Desktop Duplication API(桌面拷贝API)
- 转录组测序分析中cufflinks的使用及问题
- Python 的类的下划线命名有什么不同?
- 赠给XJ的代码规范
- SQL语句优化技巧
- HDU2069 Coin Change(暴力)
- 在Linux终端里使用wget下载百度云盘共享资源
- java 中 的反射 总类
- 记录RecycleView的数据错乱BUG解决
- 设计模式--工厂模式
- eclipse建javaEE项目的常见错误(不定期更新)
- HDOJ 1285 确定比赛名次(拓扑排序)
- hdu 5965 扫雷 ccpc 2016 合肥站
- 总结最近一周遇到的开发问题.