5F - Coin Change
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
- #include<stdio.h>
- int main()
- {
- int n,m, a,b,c,d,e;
- while(~scanf("%d", &n))
- {
- if(n)
- {
- m=;
- for(a=;a<=;a++)
- for(b=;b<=-*a;b++)
- for(c=;c<=-*a-*b;c++)
- for(d=;d<=-*a-*b-*c;d++)
- for(e=;e<=-a-b-c-d;e++)
- if(*a+*b+*c+*d+e==n)
- { m++; break; }
- printf("%d\n", m);
- }
- else printf("1\n");
- }
- return ;
- }
- // 背包怎么做T^T
5F - Coin Change的更多相关文章
- [LeetCode] Coin Change 硬币找零
You are given coins of different denominations and a total amount of money amount. Write a function ...
- HDOJ 2069 Coin Change(母函数)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU 2069 Coin Change
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- UVA 674 Coin Change(dp)
UVA 674 Coin Change 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/ ...
- JSU省赛队员选拔赛个人赛1(Coin Change、Fibbonacci Number、Max Num、单词数、无限的路、叠筐)
JSU省赛队员选拔赛个人赛1 一.题目概述: A.Coin Change(暴力求解.动态规划) B.Fibbonacci Number(递推求解) C.Max Num(排序.比较) D.单词数 ...
- C - Coin Change (III)(多重背包 二进制优化)
C - Coin Change (III) Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- Coin Change (IV) (dfs)
Coin Change (IV) Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu [Subm ...
- Coin Change (II)(完全背包)
Coin Change (II) Time Limit: 1000MS Mem ...
- [LeetCode] Coin Change 2 硬币找零之二
You are given coins of different denominations and a total amount of money. Write a function to comp ...
随机推荐
- Chrome 不能访问tensorboard解决
Chrome 不能访问tensorboard解决 Run: Cmd Result: C:\Users\think>tensorboard --logdir=C:\Users\think\sour ...
- 学JS的心路历程-JS支持面向对象?(一)
昨天在看Prototype看到JS支持面向对象,被前辈问到说那什么是面向对象?JS是面向对象语言吗? 便开始了一连串艰辛爬文过程,今天就来看一下两者有什么差异吧(rgwyjc)! 首先面向对象有三大特 ...
- CSS 字体术语
字体有些术语需要了解. 衬线字体 衬线字体指的是有衬线的字体,又称为有衬线体.衬线字.曲线描边字,俗称白体字. 衬线指的是字形笔画末端的装饰细节部分. 衬线字体便于阅读,通常用于长篇文本. 常见的衬线 ...
- pl2303 驱动
https://blog.csdn.net/ouening/article/details/70947759
- vuex this.$store.state.属性和mapState的属性中的一点点区别
做泰康公众号的项目时候有一个需求创建公众号的时候后台有一个社区id提供给后台展现人员和部门,在群发消息时候也要给后台一个社区id只不过获取社区的id接口和上一个不是一样的,本来在页面中写了两个sele ...
- Link & Redirect
[Link] Link标签,用于实现React-Router功能的跳转.(意思是就不要使用a标签了) 1)to:string,指明要跳转的path. import { Link } from 'rea ...
- Linux系统缓冲区溢出
Linux系统下穿越火线-缓冲区溢出 原理:crossfire 1.9.0 版本接受入站 socket 连接时存在缓冲区溢出漏洞. 工具: 调试工具:edb: ###python在漏洞溢出方面的渗透测 ...
- jvisual修改内存大小
jvisual(Java VisualVM)导入dump文件内存不足解决办法: 当通过jvusual调整-Xmx参数: c:/program files/java/jdk1.6/lib/visualv ...
- MySQL 按指定字段自定义列表排序
问题描述 大家都知道, mysql 中按某字段升序排列的 SQL 为 (以 id 为例, 下同): SELECT * FROM `MyTable` WHERE `id` IN (1, 7, 3, 5) ...
- jdbc java远程连接mysql数据库服务器
首先,需要注意以下几点: 1.手机需要获得可以访问网络的权限: 2.导入的jdbc驱动的版本需要与mysql服务器的版本相近: 3.mysql默认的访客是只允许本机(localhost),不允许其他主 ...