HDU 2069 Coin Change
Coin Change
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10924 Accepted Submission(s): 3669
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
母函数
import java.io.*;
import java.util.*;
public class Main {
public int money[]={1,5,10,25,50};
public int M=250;
public int patten[][]=new int[M+1][M+1];
public static void main(String[] args) {
new Main().work();
}
public void work(){
init();
Scanner sc=new Scanner(new BufferedInputStream(System.in));
while(sc.hasNextInt()){
int n=sc.nextInt();
if(n==0){
System.out.println(1);
}
else{
int sum=0;
for(int i=1;i<=n&&i<=100;i++){
sum+=patten[i][n];
}
System.out.println(sum);
}
}
}
public void init(){
patten[0][0]=1;
for(int i=0;i<5;i++){
for(int j=1;j<=100;j++){
for(int k=money[i];k<=M;k++){
patten[j][k]=patten[j][k]+patten[j-1][k-money[i]];
}
}
}
}
}
HDU 2069 Coin Change的更多相关文章
- hdu 2069 Coin Change(完全背包)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- 题解报告:hdu 2069 Coin Change(暴力orDP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of ...
- HDU 2069 Coin Change(完全背包变种)
题意:给你5种银币,50 25 10 5 1,问你可以拼成x的所有可能情况个数,注意总个数不超过100个 组合数问题,一看就是完全背包问题,关键就是总数不超过100个.所有我们开二维dp[k][j], ...
- HDOJ 2069 Coin Change(母函数)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu2069(Coin Change)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Coin Change Time Limit: 1000/1000 MS (Java/Other ...
- [LeetCode] Coin Change 硬币找零
You are given coins of different denominations and a total amount of money amount. Write a function ...
- hdu 2069 限制个数的母函数(普通型)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- UVA 674 Coin Change(dp)
UVA 674 Coin Change 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/ ...
- JSU省赛队员选拔赛个人赛1(Coin Change、Fibbonacci Number、Max Num、单词数、无限的路、叠筐)
JSU省赛队员选拔赛个人赛1 一.题目概述: A.Coin Change(暴力求解.动态规划) B.Fibbonacci Number(递推求解) C.Max Num(排序.比较) D.单词数 ...
随机推荐
- php基础知识【函数】(1)数组array
一.排序 1.sort -- 从最低到最高排序,删除原有的键名,赋予新的键名[字母比数字高] 2.rsort -- 逆向排序(最高到最低),删除原有的键名,赋予新的键名[字母比数字高] 3.asort ...
- C#快递单号查询源码
源码本人测试过,没有啥问题,能查询快递单号,支持的快递还挺多,圆通快递.申通快递.韵达快递的都支持单号查询的,程序是通过向爱快递(www.aikuaidi.cn)接口传输参数来查询快递单号,我直接把代 ...
- opencv 构造训练器
D:/face 构造face训练器为例 一:样本创建 训练样本分为正例样本和反例样本,其中正例样本是指待检目标样本,反例样本指其它任意图片. 负样本可以来自于任意的图片,但这些图片不能包含目标特征 ...
- Sharepoint 问题集锦 - external list (外部列表)
使用Sharepoint开发过程中遇到的问题总结. 错误1: Unable to display this Web Part. To troubleshoot the problem, open th ...
- uboot环境变量初始化
一.环境变量概述 1.环境变量的概念 可以理解为用户对软件的全局配置信息,这部分信息应该可以从永久性存储器上读取,能被查询,能被修改. 启动过程中,应该首先把环境变量读取到合适的内存区域,然后利用环境 ...
- Xcode7之后常见问题整理-b
一.Xcode7,iOS9之后传出来的什么Xcode有鬼,被植入代码片段什么的,可以看看,了解一下http://drops.wooyun.org/news/8864 二.bitcode问题--未正确设 ...
- iOS 宏定义_16进制色值转化为RGB返回UIColor类型对象
// 十六进制颜色 #define COLOR_WITH_HEX(hexValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) ...
- sqlplus 打印很乱,而且很短就换行
set linesize 可以解决 设置行打印的字符长度,set linesize 400解决
- Nodejs and json
http://cnodejs.org/topic/51bbe16960af11cd33304b75 http://www.cnblogs.com/nano/archive/2012/05/09/249 ...
- Android 通过开源框架AsyncHttpClient进行get和post请求
使用时无需将这些代码放入子线程去执行,因为其内部已经封装到一个线程中运行了! public void asyncHttpClientGet(View view) { AsyncHttpClient c ...