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. 30、Java并发性和多线程-阿姆达尔定律

    以下内容转自http://ifeve.com/amdahls-law/: 阿姆达尔定律可以用来计算处理器平行运算之后效率提升的能力.阿姆达尔定律因Gene Amdal 在1967年提出这个定律而得名. ...

  2. JAVA学习第四十一课 — 泛型的基本应用(一)

    泛型是JDK1.5以后出现的安全机制,简化机制,提高安全性 泛型的长处 1.将执行时出现的问题ClassCastException转移到了编译时期 2.避免了强制转换的麻烦 <>在当操作的 ...

  3. Linux内核之于红黑树and AVL树

    为什么Linux早先使用AVL树而后来倾向于红黑树?       实际上这是由红黑树的有用主义特质导致的结果,本短文依旧是形而上的观点.红黑树能够直接由2-3树导出.我们能够不再提红黑树,而仅仅提2- ...

  4. FFmpeg总结(三)AV系列结构体之AVCodecContext

    位置: 描写叙述:主要扩展API的结构体 New fields can be added to the end with minor version bumps. Removal, reorderin ...

  5. Linux下使用Vi是方向键变乱码 退格键不能使用的解决方法

    在Linux下编辑一些文件.这就涉及到了vi这个编辑器了.在Linux下,初始使用vi的时候有点问题.就是在编辑模式下使用方向键的时候,并不会使光标移动,而是在命令行中出现[A [B [C [D之类的 ...

  6. C++学习之new与delete、malloc与free

    在C/C++的面试时,对于new/delete和malloc/free这两对的使用和区别经常被考查到,如果这种基础的问题都答不上来,估计很难过面试了.这篇文章仅仅是浅显的讲一下,仅供参考. 一.new ...

  7. android传感器;摇一摇抽签功能

    package com.kane.sensortest; import java.util.Random; import android.hardware.Sensor; import android ...

  8. research plan

  9. PCB Windows Petya(永恒之蓝)勒索病毒补丁检测代码

    公司内部电脑招受到新的勒索病毒Petya(永恒之蓝)攻击,直接导致受攻击的电脑系统崩贵无法启动,这次勒索病毒攻击影响范围之广,IT,人事,工程,生产,物控等部门都无一幸免,对整个公司运转产生了非常严重 ...

  10. E20170919-hm

    infinity   n. <数>无穷大; 无限的时间或空间;