Holding Bin-Laden Captive!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19908    Accepted Submission(s): 8865

Problem Description
We all know that Bin-Laden is a notorious terrorist, and he has disappeared for a long time. But recently, it is reported that he hides in Hang Zhou of China! 
“Oh, God! How terrible! ”

Don’t be so afraid, guys. Although he hides in a cave of Hang Zhou, he dares not to go out. Laden is so bored recent years that he fling himself into some math problems, and he said that if anyone can solve his problem, he will give himself up! 
Ha-ha! Obviously, Laden is too proud of his intelligence! But, what is his problem?
“Given some Chinese Coins (硬币) (three kinds-- 1, 2, 5), and their number is num_1, num_2 and num_5 respectively, please output the minimum value that you cannot pay with given coins.”
You, super ACMer, should solve the problem easily, and don’t forget to take $25000000 from Bush!

 
Input
Input contains multiple test cases. Each test case contains 3 positive integers num_1, num_2 and num_5 (0<=num_i<=1000). A test case containing 0 0 0 terminates the input and this test case is not to be processed.
 
Output
Output the minimum positive value that one cannot pay with given coins, one line for one case.
 
Sample Input
1 1 3
0 0 0
 
Sample Output
4
 
三种硬币,输入三种硬币的个数,问所有这些硬币所不能支付的钱数的最小值。
用母函数解决,虽说做得有点久,思想基本掌握。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int c1[];
int c2[];
int c3[]; int main()
{
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c)!=EOF&&(a||b||c))
{
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2));
memset(c3,,sizeof(c3));
for(int i=; i<=a; i++)
c1[i]=;
for(int i=; i<=a; i++)
for(int j=; j<=*b; j+=)
c2[i+j]+=c1[i]; for(int i=;i<=a+b*;i++)
{
c1[i]=c2[i];
c2[i]=;
}
for(int i=; i<=(a*)+(b*); i++)
for(int j=; j<=*c; j+=)
c2[i+j]+=c1[i];
for(int i=;i<=a+b*+c*;i++)
c1[i]=c2[i];
/*for(int i=0;i<=a+2*b+5*c;i++)
cout<<c1[i]<<endl;
cout<<endl;*/
for(int i=;i<=a+*b+*c+;i++)
if(c1[i]==)
{
printf("%d\n",i);
break;
}
}
return ;
}

HDU_1085_Holding Bin-Laden Captive!_母函数的更多相关文章

  1. HDU 1085 Holding Bin-Laden Captive! (母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  2. Holding Bin-Laden Captive!(母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  3. HDOJ 1085 Holding Bin-Laden Captive! (母函数)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  4. HDOJ/HDU 1085 Holding Bin-Laden Captive!(非母函数求解)

    Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for ...

  5. hdu 2079 选课时间_母函数

    题意:需要学够n学分,有k个情况(x学分,y个相同学分的课) 解法:套母函数模板 #include <iostream> #include<cstdio> using name ...

  6. hdu1085 Holding Bin-Laden Captive!(母函数)

    简单的母函数应用. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstrin ...

  7. Bash 中的 _ 是不是环境变量

    首先,我们想到的会是 export(等价于 declare -x)命令: $ export | grep 'declare -x _=' 没有找到,那么结论就是 _ 不是环境变量?当然没那么简单,否则 ...

  8. python_login输入三次错误密码锁定密码_密码不允许为空

    #!/usr/bin/env python #_*_coding:utf-8_*_ #by anthor zhangxiaoyu 2017-01-10 import getpass import os ...

  9. Python-老男孩-01_基础_文件IO_函数_yield_三元_常用内置函数_反射_random_md5_序列化_正则表达式_time

    Python2.7 缩进统一: 约定  常量 大写 , 变量  小写 判断一个变量在内存中的地址,也能看出是不是一个值 id()函数 >>> x = 'abc' >>&g ...

随机推荐

  1. js部分基础

    1.js的基本类型有哪些?引用类型有哪些?null和undefined的区别. 基础类型:number,null,regex,string,boolean 引用类型 : object,function ...

  2. AE 创建

    using System; using System.Drawing; using System.Runtime.InteropServices; using ESRI.ArcGIS.ADF; usi ...

  3. Rsync命令的使用

    Rsync的命令格式能够为下面六种: rsync [OPTION]- SRC DEST rsync [OPTION]- SRC [USER@]HOST:DEST rsync [OPTION]- [US ...

  4. hihoCoder #1175 : 拓扑排序&#183;二

    [题目链接]:click here~~ 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描写叙述 小Hi和小Ho所在学校的校园网被黑客入侵并投放了病毒.这事在校内BBS上立马引 ...

  5. shell 例程 —— 解决redis读取稳定性

    问题背景: php读取线上redis数据,常常不稳定,数据响应时有时无. 解决方法:多次读取.每次读取全部上一次没读出的数据,直到全部获取. 本文实现用shell进行多次redis数据读取, 每次取出 ...

  6. iOS_截屏并裁剪

    截图使用场景: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5lbnQ=/font/5a6L5L2T/fontsize/400/fil ...

  7. GTK经常使用控件之笔记本控件( GtkNotebook )

    笔记本控件,能够让用户标签式地切换多个界面. 当我们须要多窗体切换时,使用笔记本控件是一个明智的选择. 笔记本控件的创建: GtkWidget *gtk_notebook_new(void); 返回值 ...

  8. ios3--UIView的常见方法

    // // ViewController.m // 07-UIView的常见方法 // #import "ViewController.h" @interface ViewCont ...

  9. Android连接热点的Socket文件传输

    最近把测试丢过来的种种BUG解决后,终于有时间去研究研究Socket通信,再加上以前做的WiFi连接和热点开启,于是有了现在的这篇博文:创建热点发送文件,让另一台手机连接热点接收文件. 效果图: 两台 ...

  10. Scala快速统计文件中特定单词,字符的个数

    val fileContent=Source.fromFile("/home/soyo/桌面/ss5.txt").getLines.mkString(",") ...