Coin Change

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10289    Accepted Submission(s): 3451

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.

 
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
11
26
 
Sample Output
4
13
 
Author
Lily
 
Source
 
Recommend
linle
 
 //加一维限制数量。。。。。。

 #include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int value[]={,,,,,}; int c1[][],c2[][];
int n; int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2)); for(int i=;i<=min(n,);i++)
{
c1[i][i]=;
} for(int i=;i<=;i++)
{
for(int j=;j<=n;j++)
{
for(int k=;k+j<=n;k+=value[i])
{
for(int l=;l<=&&l+k/value[i]<=;l++)
{
c2[j+k][l+k/value[i]]+=c1[j][l];
}
}
} for(int j=;j<=n;j++)
{
for(int k=;k<=;k++)
{
c1[j][k]=c2[j][k];
c2[j][k]=;
}
}
} int ans=;
for(int j=;j<=;j++)
{
ans+=c1[n][j];
} printf("%d\n",ans); }
return ;
}

HDOJ 2069 Coin Change(母函数)的更多相关文章

  1. HDU 2069 Coin Change

    Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...

  2. hdu 2069 Coin Change(完全背包)

    Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  3. 题解报告:hdu 2069 Coin Change(暴力orDP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of ...

  4. HDU 2069 Coin Change(完全背包变种)

    题意:给你5种银币,50 25 10 5 1,问你可以拼成x的所有可能情况个数,注意总个数不超过100个 组合数问题,一看就是完全背包问题,关键就是总数不超过100个.所有我们开二维dp[k][j], ...

  5. hdu2069(Coin Change)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Coin Change Time Limit: 1000/1000 MS (Java/Other ...

  6. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  7. UVA 674 Coin Change(dp)

    UVA 674  Coin Change  解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/ ...

  8. JSU省赛队员选拔赛个人赛1(Coin Change、Fibbonacci Number、Max Num、单词数、无限的路、叠筐)

    JSU省赛队员选拔赛个人赛1 一.题目概述: A.Coin Change(暴力求解.动态规划)     B.Fibbonacci Number(递推求解) C.Max Num(排序.比较) D.单词数 ...

  9. C - Coin Change (III)(多重背包 二进制优化)

    C - Coin Change (III) Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

随机推荐

  1. xm 命令详解

    xm 命令详解 xm addlabel label dom configfile [policy] xm addlabel label res resource [policy] 增加了名称为labe ...

  2. eth0: error fetching interface information: Device not found

    转载,原文出处:http://zh888.blog.51cto.com/1684752/775447 亲测有效,感谢作者!!! ----------------------------分割线----- ...

  3. 64.OV7725初始化配置

    所有的结局都是好的,不好,是因为你还有坚持到最好. OV7725摄像头的初始化配置,需要SCCB总线即IIC接口配置.先发送配置数据到OV7725中,然后通过随机读取对应地址的数据来验证数据是否写进去 ...

  4. Jsp实现筛选并压缩文件批量下载

    Jsp实现筛选并压缩文件批量下载 首先明确一下需求,网页端点击一下button,传递特定的参数到download.jsp网页,筛选文件,对过滤得到的文件进行压缩,然后返回前端一个压缩包下载. 以下的代 ...

  5. Labview实现频率调制(FM)

    Labview实现频率调制(FM) 频率调制的原理: 自己的实现为三角函数分解 根据这个公式在Labview中连线则可以得到最终的波形输出 实现效果 从频域图中可以看出,载波信号的频率被调制,原本为双 ...

  6. FPGA内部信号避免高阻态

    RT,否则警告Warning: Tri-state node(s) do not directly drive top-level pin(s),会利用或门代替中间的扇出fan-out. 原因:在进行 ...

  7. < java.lang >-- StringBuffer字符串缓冲区

    构造一个其中不带字符的字符串缓冲区,初始容量为 16 个字符. 特点: 1:可以对字符串内容进行修改. 2:是一个容器. 3:是可变长度的. 4:缓冲区中可以存储任意类型的数据. 5:最终需要变成字符 ...

  8. Ant学习---第三节:使用Ant实现一个最小的项目编译

    1.编译 .java 文件,生成 .jar 包,代码如下: <?xml version="1.0" encoding="UTF-8"?> <p ...

  9. PSP0表格二

    一 项目计划日志 周活动总结表 姓名: 陆宇 日期:2015. 3. 21 日期       任务 听课 编写程序 阅读课本 准备考试 日总计/(min) 周日 60 30 90 周一 300 0 1 ...

  10. 结队开发项目—NABC模型

    特点:可以避免食堂的用餐高峰,从而使使用者节约时间 need:很多学生中午下课在食堂吃饭会遭遇用餐高峰,使用这款软件,可以提前订饭,按时送达,从而避免食堂的用餐高峰期. approach:学生可以提前 ...