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

  1. 11
  2. 26

Sample Output

  1. 4
  2. 13
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,m, a,b,c,d,e;
  5. while(~scanf("%d", &n))
  6. {
  7. if(n)
  8. {
  9. m=;
  10. for(a=;a<=;a++)
  11. for(b=;b<=-*a;b++)
  12. for(c=;c<=-*a-*b;c++)
  13. for(d=;d<=-*a-*b-*c;d++)
  14. for(e=;e<=-a-b-c-d;e++)
  15. if(*a+*b+*c+*d+e==n)
  16. { m++; break; }
  17. printf("%d\n", m);
  18. }
  19. else printf("1\n");
  20. }
  21. return ;
  22. }
  1. // 背包怎么做T^T

5F - Coin Change的更多相关文章

  1. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  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. UVA 674 Coin Change(dp)

    UVA 674  Coin Change  解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/ ...

  5. JSU省赛队员选拔赛个人赛1(Coin Change、Fibbonacci Number、Max Num、单词数、无限的路、叠筐)

    JSU省赛队员选拔赛个人赛1 一.题目概述: A.Coin Change(暴力求解.动态规划)     B.Fibbonacci Number(递推求解) C.Max Num(排序.比较) D.单词数 ...

  6. C - Coin Change (III)(多重背包 二进制优化)

    C - Coin Change (III) Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

  7. Coin Change (IV) (dfs)

    Coin Change (IV) Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu [Subm ...

  8. Coin Change (II)(完全背包)

                                                               Coin Change (II) Time Limit: 1000MS   Mem ...

  9. [LeetCode] Coin Change 2 硬币找零之二

    You are given coins of different denominations and a total amount of money. Write a function to comp ...

随机推荐

  1. 身份证号码 正则表达式 jquery

    现在的身份证为18位(最后一位可以是数字,可以是x,可以是X),老的身份证是15位(纯数字). 所以正则是: /(^\d{15}$)|(^\d{17}[\d|x|X]$)/ 扩展: 1 正则表达式的创 ...

  2. windows下一分钟配置ngnix实现HLS m3u8点播

    1. 下载 nginx-1.5.10 for windows 2. 修改配置文件nginx-1.5.10\conf\nginx.conf,增加以下行到最后一个"}"的前一行: lo ...

  3. php支付宝接口 的使用

    下载地址(java/php都有) https://doc.open.alipay.com/doc2/detail?treeId=66&articleId=103571&docType= ...

  4. 解题1(Suduku)

    题目描述 问题描述:数独(Sudoku)是一款大众喜爱的数字逻辑游戏.玩家需要根据9X9盘面上的已知数字,推算出所有剩余空格的数字,并且满足每一行.每一列.每一个粗线宫内的数字均含1-9,并且不重复. ...

  5. Java读取文件时第一行出现乱码“?”问号

    我们在使用Java在读取文件(txt.dat等)时,如果文件不是utf-8格式的话,读取结果会出现,中文字符变乱码的情况,所以一般在读取时转为UTF-8格式读取. 但这时会出现一种情况,第一次读取第一 ...

  6. Ambertools15安装(详细)

    这篇博文专门讲述 Ambertools15的安装方法,尽管Ambertools16版本已经正是发行了,但两者在安装方式上没有任何区别.比较偏爱Ambertools15的原因主要还是在容量方面(230M ...

  7. Vue.Draggable:基于 Sortable.js 的 Vue 拖拽组件使用中遇到的问题

    Sortable.js 介绍 https://segmentfault.com/a/1190000008209715 项目中遇到的问题: A - 我需要在项目的拖拽组件中,使用背景 1 - 想到的第一 ...

  8. OpenVPN 2.2.1 之后期维护

    一.Openvpn 用户注销 每个公司都会用员工离职,因此注销vpn用户也就成了运维人员日常工作的一部分. 其实Openvpn在设计的时候也想到了这点,我们可以使用 revoke-full shell ...

  9. enlarge your dataset

    列举常见的几种数据集增强方法: 1.flip  翻折(左右,上下) # NumPy.'img' = A single image. flip_1 = np.fliplr(img) # TensorFl ...

  10. LibreOJ 6277. 数列分块入门 1

    题目链接:https://loj.ac/problem/6277 参考博客:https://www.cnblogs.com/stxy-ferryman/p/8547731.html 两个操作,区间增加 ...