Coin Change——中级
1 Sec 32 MB | Markdown 显示标签
简单 (*1100) 枚举 动态规划
369 | 1124 |
通过 | 提交 |
题目描述
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.**
---
*翻译仅供参考:*
你有 $5$ 种类型的硬币,面值分别为 $50,25,10,5,1$ 元。对于给定的金额 $E$,你需要算出有多少种硬币的组合情况能够凑出这个金额。
例如,$E=11$ 时,你可以使用一枚 $10$ 元及一枚 $1$ 元的硬币、或是两枚 $5$ 元及一枚 $1$ 元的硬币、或是一枚 $5$ 元及六枚 $1$ 元的硬币、或是十一枚 $1$ 元的硬币。总共有 $4$ 种组合情况。
注意,如果 $E=0$,也当作有一种组合情况。
你需要找出在**至多只使用 $100$ 枚硬币**的前提下的组合情况数量。
输入格式
The input file contains any number of lines, each one consisting of a number ( $\le 250$ ) for the amount of money in cents.
---
**多组数据,请处理到文件结束。**
每组数据占一行,包含一个整数 $E\ (0\le E\le 250)$.
输出格式
For each input line, output a line containing the number of different ways of making changes with the above 5 types of coins.
---
对于每组数据,在一行内输出一个整数,表示组合情况数。
样例输入 #1
11 26
样例输出 #1
4 13
来源
浙江工业大学网络选拔赛