Coin Change

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

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 | We have carefully selected several similar
problems for you: 1171 1398 1085 1028 2152
 
第一次写完全背包的题,这题很简单,不过要注意硬币数目不能大于100
 
题意:给你面值有1,5,10,25,50的币种,然后随意输入一个钱的数目,问用这些面值刚好凑成这个钱的方法有多少个(最多100个硬币)
 
附上代码:
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dp[][];
int main()
{
int coin[]= {,,,,};
int i,j,n,m,k;
memset(dp,,sizeof(dp));
dp[][]=;
for(i=; i<; i++) //用的硬币
{
for(k=; k<=; k++) //硬币数目
{
for(j=coin[i]; j<=; j++)
{
dp[k][j]+=dp[k-][j-coin[i]];
}
} }
while(~scanf("%d",&n))
{
int ans=;
for(i=; i<=; i++)
ans+=dp[i][n];
printf("%d\n",ans);
}
return ;
}

hdu 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(完全背包变种)

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

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

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

  4. HDOJ 2069 Coin Change(母函数)

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

  5. uva674 Coin Change ——完全背包

    link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  6. Light oj 1233 - Coin Change (III) (背包优化)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1233 题目就不说明了. 背包的二进制优化,比如10可以表示为1 2 4 3,而 ...

  7. hdu2069(Coin Change)

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

  8. UVA.674 Coin Change (DP 完全背包)

    UVA.674 Coin Change (DP) 题意分析 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 每种硬币的数量是无限的.典型完全背包. 状态 ...

  9. Lightoj 1231 - Coin Change (I) (裸裸的多重背包)

    题目链接: Lightoj  1231 - Coin Change (I) 题目描述: 就是有n种硬币,每种硬币有两个属性(价值,数目).问用给定的硬币组成K面值,有多少种方案? 解题思路: 赤果果的 ...

随机推荐

  1. Wndows下Apache+php+Mysql环境的搭建及其涉及的知识

    一.安装Apache 1. 在网上搜索以下3个文件,以及找一个地方新建一个文件夹 好吧,这里有下载链接:http://pan.baidu.com/s/1hr9IdSS 文件夹内有:apache,mys ...

  2. SAS信用评分之模型拟合以及验证的大坑

    SAS信用评分之模型拟合以及验证的大坑 今天的内容是来讲我这段时间被模型拟合和模型验证坑过的那些事.我也是千辛万苦终于是把模型给建出来了.此处应该有掌声.因为模型老是效果不好这件事,我躲在被窝里哭了好 ...

  3. spring boot 异常处理(转)

    spring boot在异常的处理中,默认实现了一个EmbeddedServletContainerCustomizer并定义了一个错误页面到"/error"中,在ErrorMvc ...

  4. Jmeter压测报错:Non HTTP response code: java.net.ConnectExceptionexception的解决办法

    前一段时间进行jmeter压测时,一直报错,查看了下日志才发现报了一堆Non HTTP response code: java.net.ConnectExceptionexception,直接jmet ...

  5. git gc干了啥

    前几天在写升级项目的时候发现./git/objects/pack/下的idx和pack文件是只读的,用java在windows下删除会抛异常,然后把只读属性改掉就好了. 于是就想弄清楚这两个文件的作用 ...

  6. Significance A and B for protein ratios

    实验设计中,一般会做三个生物学重复来确保结果的准确性,尤其在下游分析中.但有时会遇到没有生物学重复,而又需要进行差异分析的情况,这时一般建议考虑foldchange即可,因为根本无法进行T-test等 ...

  7. yum源配置及详解

      红帽系列中,进行软件安装可以有三种方法,编译安装,rpm包安装,和yum源安装.其中yum方法安装最简单,因为它可以自动解决软件包之间的依赖关系... 一.常用yum源 yum源可以来源于多种文件 ...

  8. js中的replace问题和textarea回车符问题

    在textarea中输入回车符 在js读取textarea中的值有\r\n然后到业务层转换到string中就有可能变成空格形式然后被存入数据库,当在取出此值的时候则会变成空格的形式,因此我们需要将不显 ...

  9. Black-White-Blocks

    微信小程序黑白块游戏 代码如下: //play.js // play var app = getApp() Page({ data: { typeName: '计时模式', score: 0, tim ...

  10. 元素的高度(基于vue)

    const viewH =el.target.offsetHeight;//可见高度 const contentH =el.target.scrollHeight;//内容高度 const scrol ...