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. SynchronizationContext一篇

    SynchronizationContext context; 最近写代码用到了这个,特别记录一下. 作用如下: // 摘要: // 提供在各种同步模型中传播同步上下文的基本功能. public cl ...

  2. oracle11g rman验证备份有效性

    RMAN> restore validate controlfile; Starting restore at 21-NOV-13using target database control fi ...

  3. 关于EF分页查询报错(Count must have a non-negative value.)的解决方案

    具体的异常信息如下,一开始没有写日志只看到错误信息:Count must have a non-negative value.,从表面意思可以看出来是Count值出现了负数,所以报错,查了半天的原因也 ...

  4. R 中安装xlsx包缺少java环境解决方案

    1.安装Java程序(官网win7 64位系统的Java安装程序及网址http://www.java.com/zh_CN/download/manual.jsp),选择windows 64位脱机安装到 ...

  5. 细说Debug和Release区别

    VC下Debug和Release区别 最近写代码过程中,发现 Debug 下运行正常,Release 下就会出现问题,百思不得其解,而Release 下又无法进行调试,于是只能采用printf方式逐步 ...

  6. 使用工厂bean和Utility Schema定义集合

    工厂bean是实现了beanFactory接口的bean,也可以继承AbstractFactoryBean,主要是用于在给定属性参数之后自动创建一个bean对象. 我们在使用基本集合标记定义集合时,不 ...

  7. bat文件编写(无线承载网络设置)

    就弄个例子,自己看执行效果,然后模仿写就行. 1)获取当前时间: @echo off set YEAR=%date:~0,4% set MONTH=%date:~5,2% set DAY=%date: ...

  8. html5 shiv

    使用html5标签吧!ie6.ie7.ie8不支持怎么办?它的原理是如此的简单:    1.document.createElement("ele");  // js虚拟创建一个元 ...

  9. ios中怎么获得当前版本号

    NSString *version = [NSBundle mainBundle].infoDictionary[(__bridge NSString *)kCFBundleVersionKey];

  10. 用Swift重写公司OC项目(Day2)--创建OC与Swift的桥接文件,进而调用OC类库

    昨天把项目中的图标以及启动转场图片弄好了,那么今天,我们可以开始慢慢进入到程序的编写当中了. 由于swift较新,所以类库还不够完善,但是不用担心,苹果早就出了解决方案,那就是使用桥接文件,通过桥接文 ...