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 ...
随机推荐
- ArcGIS案例学习笔记-点集中最近点对和最远点对
ArcGIS案例学习笔记-点集中最近点对和最远点对 联系方式:谢老师,135-4855-4328,xiexiaokui@qq.com 目的:对于点图层,查找最近的点对和最远的点对 数据: 方法: 1. ...
- Assetbundle创建与加载
[Assetbundle创建与加载] Unity有两种动态加载机制:一种是Resource.Load.一种是AssetBundle.Assetbundle是Unity Pro提供的功能,它可以把多个游 ...
- Oracle Error
1. TNS:listener does not currently know of service requested in connect descriptor 数据库连接出错
- 吴裕雄 15-MySQL LIKE 子句
我们知道在 MySQL 中使用 SQL SELECT 命令来读取数据, 同时我们可以在 SELECT 语句中使用 WHERE 子句来获取指定的记录.WHERE 子句中可以使用等号 = 来设定获取数据的 ...
- JAVA集合操作异常 ---------Collections.unmodifiableCollection
1.问题原因 这两天在做开发的时候,在一个首页的列表哪里操作了ArrayList集合,在做递归删除的时候用的是Iterator对象(至于为什么用,来个链接https://blog.csdn.net/m ...
- struts原理图
n the diagram, an initial request goes to the Servlet container (such as Jetty or Resin) which is pa ...
- 用R包中heatmap画热图
一:导入R包及需要画热图的数据 library(pheatmap) data<- read.table("F:/R练习/R测试数据/heatmapdata.txt",head ...
- 大型运输行业实战_day15_1_全文检索之Lucene
1.引入 全文检索简介: 非结构化数据又一种叫法叫全文数据.从全文数据(文本)中进行检索就叫全文检索. 2.数据库搜索的弊端 案例 : select * from product whe ...
- MySQL 事务 隔离级别
前两天面试,问到了四种隔离级别,当时觉得大多数数据库都为read committed,结果没想到mysql是个例外.在此做一下隔离级别和各种数据库锁的使用. 首先说一下ACID四大特性: 四大特性 ...
- ORM之查询
一.对象查询 1.正向查询 ret1=models.Book.objects.first() print(ret1.title) print(ret1.price) print(ret1.publis ...