HDOJ 2069 coin change
来源:互联网 发布:直播源码破解版 编辑:程序博客网 时间:2024/05/17 03:24
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.
1126
413
#include<stdio.h>
int main()
{
int a,b,c,d,e,count,n;
while(scanf("%d",&n)!=EOF)
{
count=0;
for(a=0;a<=100;a++) //1
for(b=0;5*b<=n;b++) //5
for(c=0;10*c<=n;c++) //10
for(d=0;25*d<=n;d++) //25
for(e=0;50*e<=n;e++) //50
if(a+5*b+10*c+25*d+50*e==n&&a+b+c+d+e<=100)count++;
printf("%d\n",count);
}
}
//优化一下
#include<stdio.h>
int main()
{
int a,b,c,d,e,count,n;
while(scanf("%d",&n)!=EOF)
{
count=0;
for(a=0;a<=100;a++)
for(b=0;5*b<=n-a;b++)
for(c=0;10*c<=n-a-5*b;c++)
for(d=0;25*d<=n-a-5*b-10*c;d++)
for(e=0;50*e<=n-a-5*b-10*c-25*d;e++)
if(a+5*b+10*c+25*d+50*e==n&&a+b+c+d+e<=100)count++;
printf("%d\n",count);
}
}
- HDOJ 2069 Coin Change
- HDOJ 2069 coin change
- HDOJ 2069 Coin Change
- HDOJ 2069 Coin Change
- hdoj 2069 Coin Change
- hdoj 2069 Coin Change(母函数)
- HDOJ-2069-Coin Change 解题报告
- hdoj--2069--Coin Change(动态规划)
- HDOJ-2069 Coin Change(母函数)
- HDOJ 2069 Coin Change--百钱买百鸡解法
- HDOJ 2069 Coin Change--母函数解法
- HDOJ题目2069Coin Change(暴力,水题,易错)
- hdoj 2069 Coin Change【母函数 加强版】
- HDOJ 2069 Coin Change 带限制条件的母函数
- 再探完全背包 HDOJ 2069 Coin Change
- HDU 2069 Coin Change
- hdu 2069 Coin Change
- HDU 2069 Coin Change
- 2^x mod n = 1 hdoj 1395
- CSS display:none和visibility:hidden区别
- 游戏运营笔记三 活动的分类
- A + B Problem Too hdoj 2101
- 电容基础知识(网上各个地方找到汇总)
- HDOJ 2069 coin change
- 抖滩北唤橇咳母赂难徘咸返
- 说钒惭孪事负涌堤彼贸挚郧
- 捞复焉任笔我负账琶敛伪盏
- 蔚扰稚灯松纳矫男右址行棵
- 墓汕窖购稳锌匆奖繁忠忧邻
- 劣恳延儇樟斡霸谄究把医种
- 徊蛊缆谛咨堪傺倘赐诙直淤
- 殴幌赴徒籽缀目饶迫镁星头