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

题意:给你面值有1,5,10,25,50的币种,然后随意输入一个钱的数目,问用这些面值刚好凑成这个钱的方法有多少个(最多100个硬币)

思路:完全背包

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int a[5] = { 1,5,10,25,50 };
ll dp[255][101];//dp[j][k]:用k个硬币组成j值的个数
int main()
{
int n;
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i < 5; i++) {
for (int k = 1; k <= 100; k++) {//k个硬币
for (int j = a[i]; j <= 250; j++) {
dp[j][k] += dp[j - a[i]][k - 1];
}
}
}
while (cin >> n) {
int res = 0;
for (int i = 0; i <= 100; i++) {
res += dp[n][i];
}
cout << res << endl;
}
return 0;
}

#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 Su ...

  2. HDOJ 2069 Coin Change(母函数)

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

  3. HDU 2069 Coin Change

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

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

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

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

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

  6. uva674 Coin Change ——完全背包

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

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

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

  8. hdu2069(Coin Change)

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

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

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

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

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

随机推荐

  1. 一个NET8 AOT编译的辅助项目,让你的任何可执行应用快速部署为服务

    不知道大家有没有和小编一样,很多时候想将自己的一些应用转为服务运行,比如一些控制台应用或者.NET Core应用,但是又不想重新编码,把他们转为服务,本文将给大家提供些我使用过的方法,并提供一个基于N ...

  2. 手动部署Kraft模式Kafka集群

    手动部署Kraft模式kafka集群 基本信息 IP地址 Hostname Release Kafka-Version 172.29.145.157 iamdemo1 Centos7.9 kafka_ ...

  3. 踩坑:nacos启动报错提示需要设置JDK环境 ,报错:ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! !!

    换了个Windows11的新电脑,因为个人工作.学习需要,就重新下载了Nacos并解压使用,结果就踩了个坑,使用下面命令启动Nacos服务端时: startup.cmd -m standalone 直 ...

  4. [ABC263G] Erasing Prime Pairs

    Problem Statement There are integers with $N$ different values written on a blackboard. The $i$-th v ...

  5. 华企盾DSC无缝替换亿赛通案例

    第一种方法无缝替换亿赛通案例 1. 把DSCClient.exe和DSCService.exe添加到亿赛通的加密控制策略中,关联类型设置为*.*|,配置为落地自动解密,包括其它程序也配置成落地自动解密 ...

  6. 数字孪生和GIS融合为智慧水利带来了什么?

    数字孪生和GIS的融合为智慧水利领域带来了巨大的变革和机遇.数字孪生技术的出现,使得水利管理者和决策者能够更好地理解和管理水资源,提高水利设施的效率和可持续性.而GIS作为空间数据管理和分析工具,为数 ...

  7. 【C#】【DateTime】获取当前时间的前一天或者后一天方法学习

    假期懈怠了一阵子,因为工作环境没有网络,随即记录下当时的问题: 1.关于DateTime.Now(2023/10/07)的前一天的时间(2023/10/06),想要通过ToString转换成字符串后除 ...

  8. 从零玩转Docker之docker-compose快捷部署中间件-dockercompose2

    title: 从零玩转Docker之docker-compose快捷部署中间件 date: 2023-04-04 17:35:18.035 updated: 2023-05-13 23:08:09.5 ...

  9. Pikachu漏洞靶场 ../../(目录遍历)

    目录遍历 概述 在web功能设计中,很多时候我们会要将需要访问的文件定义成变量,从而让前端的功能便的更加灵活.当用户发起一个前端的请求时,便会将请求的这个文件的值(比如文件名称)传递到后台,后台再执行 ...

  10. 神经网络优化篇:梯度检验应用的注意事项(Gradient Checking Implementation Notes)

    梯度检验应用的注意事项 分享一些关于如何在神经网络实施梯度检验的实用技巧和注意事项. 首先,不要在训练中使用梯度检验,它只用于调试.意思是,计算所有\(i\)值的\(d\theta_{\text{ap ...