hdu 2069 Coin Change(完全背包)
Coin Change
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 16592 Accepted Submission(s):
5656
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.
consisting of a number ( ≤250 ) for the amount of money in cents.
number of different ways of making changes with the above 5 types of
coins.
#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(完全背包)的更多相关文章
- HDU 2069 Coin Change
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- HDU 2069 Coin Change(完全背包变种)
题意:给你5种银币,50 25 10 5 1,问你可以拼成x的所有可能情况个数,注意总个数不超过100个 组合数问题,一看就是完全背包问题,关键就是总数不超过100个.所有我们开二维dp[k][j], ...
- 题解报告:hdu 2069 Coin Change(暴力orDP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of ...
- HDOJ 2069 Coin Change(母函数)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- uva674 Coin Change ——完全背包
link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Light oj 1233 - Coin Change (III) (背包优化)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1233 题目就不说明了. 背包的二进制优化,比如10可以表示为1 2 4 3,而 ...
- hdu2069(Coin Change)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Coin Change Time Limit: 1000/1000 MS (Java/Other ...
- UVA.674 Coin Change (DP 完全背包)
UVA.674 Coin Change (DP) 题意分析 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 每种硬币的数量是无限的.典型完全背包. 状态 ...
- Lightoj 1231 - Coin Change (I) (裸裸的多重背包)
题目链接: Lightoj 1231 - Coin Change (I) 题目描述: 就是有n种硬币,每种硬币有两个属性(价值,数目).问用给定的硬币组成K面值,有多少种方案? 解题思路: 赤果果的 ...
随机推荐
- 洛谷 3112 [USACO14DEC]后卫马克Guard Mark——状压dp
题目:https://www.luogu.org/problemnew/show/P3112 状压dp.发现只需要记录当前状态的牛中剩余承重最小的值. #include<iostream> ...
- CWnd::Attach()具体解释
CWnd::Attach Attaches a Windows window to a CWnd object. BOOL Attach( HWND hWndNew ); Parameters ...
- pl/sql 语句块循环语句
---基本循环declarev1 number(2) :=1;begin loop dbms_output.put_line(v1); v1:=v1+1; exit when v1>10; -- ...
- Leetcode883.Projection Area of 3D Shapes三维形体投影面积
在 N * N 的网格中,我们放置了一些与 x,y,z 三轴对齐的 1 * 1 * 1 立方体. 每个值 v = grid[i][j] 表示 v 个正方体叠放在单元格 (i, j) 上. 现在,我们查 ...
- Leetcode680.Valid Palindrome II验证回文字符串2
给定一个非空字符串 s,最多删除一个字符.判断是否能成为回文字符串. 示例 1: 输入: "aba" 输出: True 示例 2: 输入: "abca" 输出: ...
- CMake学习笔记三
添加子文件夹 ADD_SUBDIRECTORY(hello) ADD_SUBDIRECTORY(libs) ADD_SUBDIRECTORY(VSLIB) SET(IDE_TARGET_NAME VS ...
- WPF/Silverlight深度解决方案:(六)HLSL自定义渲染特效之完美攻略(上)
原文:WPF/Silverlight深度解决方案:(六)HLSL自定义渲染特效之完美攻略(上) Shader Effect种位图特效及2种渲染特效,而Silverlight中仅有这2种渲染特效: Bl ...
- metro扁平UI网页组件
在线演示 本地下载
- js表格上下移动添加删除
html部分 <div onclick='fn()'>加</div> <table width="250" border="1" ...
- dba和表的备份与恢复
每个oracle数据库应该至少有一名数据库管理员(dba),对于一个小的数据库,一个dba就够了,但是对于一个大的数据库可能需要多个dba分别担负不同的管理职责.那么一个数据库管理员的主要工作是什么呢 ...