UVA 674 Coin Change (DP)

简介:

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, two 5-cent coins and one 1-cent coin, 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 7489 cents.

Input 

The input file contains any number of lines, each one consisting of a number 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

5种面值钱币,要求出兑换某个钱的方法总数:

 

}






本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5374291.html,如需转载请自行联系原作者

相关文章
|
10月前
|
人工智能 自然语言处理 数据挖掘
田渊栋团队新作祭出Agent-as-a-Judge!AI智能体自我审判,成本暴跌97%
田渊栋团队提出Agent-as-a-Judge框架,利用智能体自身评估其他智能体的性能,不仅关注最终结果,还能提供中间反馈,更全面准确地反映智能体的真实能力。该框架在DevAI基准测试中表现出色,成本效益显著,为智能体的自我改进提供了有力支持。
284 7
|
敏捷开发 安全 前端开发
改进产品的用户体验
【10月更文挑战第9天】改进产品的用户体验
378 2
|
人工智能 边缘计算 物联网
移动应用与系统:构建高效生态系统
【10月更文挑战第6天】 本文深入探讨了移动应用开发与移动操作系统之间的紧密关系,揭示了如何通过优化这两者的交互来提升用户体验和系统效率。不同于传统的技术解析,本文以实际案例为依托,展现了在快速迭代的移动技术领域中,开发者如何利用最新工具和策略,克服挑战,推动创新。通过分析当前市场趋势,本文进一步阐述了移动应用与系统协同进化的重要性及其对未来数字生态的影响。
110 1
|
机器学习/深度学习 Java Nacos
Nacos实战之配置中心与注册中心详解
Nacos实战之配置中心与注册中心详解
Nacos实战之配置中心与注册中心详解
|
存储 编译器 C++
C++从入门到精通:1.2.1简单程序编写与基本操作
C++从入门到精通:1.2.1简单程序编写与基本操作
158 0
|
数据可视化 测试技术
测试范围不清晰该咋办?
测试范围不清晰该咋办?
148 0
JDK的生成keytool证书
JDK的生成keytool证书
UVa787 - Maximum Sub-sequence Product(最大连续乘积子串)
UVa787 - Maximum Sub-sequence Product(最大连续乘积子串)
150 0
|
XML 图形学 数据格式
IOC控制反转——基础概念与实例
IOC控制反转——基础概念与实例