Holding Bin-Laden Captive!

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

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
 
Author
lcy
 
Recommend
We have carefully selected several similar problems for you:  1398 2152 2082 1709 2079 
 
一开始想用dp,但是dp[1000][1000][1000]开不了那么大(三维数组最大是[790][790][790]codeblocks亲测),所以直接找规律。要细心,wa了两次,第一次是少了3,0,1这种情况,我的答案是9,正确答案是4。第二次是因为没有写&&n1+n2+n5>0 (orz...)
 
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 1002
int n1,n2,n5; int ziji(int n1,int n2,int n5)
{
int ans;
if(n1==)ans=;
else if(n2==&&n1<)ans=;
else if(n1==&&n2==)ans=;
else if(n1==&&n2==&&n5>)ans=;
else if(n1==&&n2==&&n5>)ans=;//第一次少了这种情况
else
{
ans=n1+n2*+n5*+;
}
return ans;
} int main()
{
while(~scanf("%d%d%d",&n1,&n2,&n5)&&n1+n2+n5>)
{
cout<<ziji(n1,n2,n5)<<endl;
}
return ;
}

母函数方法:

 

HDU 1085 Holding Bin-Laden Captive!(母函数,或者找规律)的更多相关文章

  1. 【hdu 6172】Array Challenge(数列、找规律)

    多校10 1002 HDU 6172 Array Challenge 题意 There's an array that is generated by following rule. \(h_0=2, ...

  2. HDU 2147 kiki's game(博弈图上找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题目大意:给你一个n*m的棋盘,初始位置为(1,m),两人轮流操作,每次只能向下,左,左下这三个 ...

  3. HDU 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 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)

    题意: 有面值分别为1.2.5的硬币,分别有num_1.num_2.num_5个,问不能组成的最小面值是多少?(0<=每种硬币个数<=1000,组成的面值>0) 思路: 母函数解决. ...

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

    //给你面值为1,2,5的三种硬币固定的数目,求不能凑出的最小钱数 //G(x)=(1+x+...+x^num1)(1+x^2+...+x^2num2)(1+x^5+,,,+x^5num3), //展 ...

  7. HDU 1085 Holding Bin-Laden Captive!(DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1085 解题报告:有1,2,5三种面值的硬币,这三种硬币的数量分别是num_1,num_2,num_5, ...

  8. hdu 1085 Holding Bin-Laden Captive!

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

  9. HDU 1085 Holding Bin-Laden Captive --生成函数第一题

    生成函数题. 题意:有币值1,2,5的硬币若干,问你最小的不能组成的币值为多少. 解法:写出生成函数: 然后求每项的系数即可. 因为三种硬币最多1000枚,1*1000+2*1000+5*1000=8 ...

随机推荐

  1. iOS8 WebKit库之——WKWebView篇

    iOS8 WebKit库之--WKWebView篇 webkit使用WKWebView来代替IOS的UIWebView和OSX的WebView,并且使用Nitro JavaScript引擎,这意味着所 ...

  2. JSP标签:jsp内置标签、jstl标签、自定义标签

     一.jsp标签的分类: 1)内置标签(动作标签): 不需要在jsp页面导入标签 2)jstl标签: 需要在jsp页面中导入标签 3)自定义标签 : 开发者自行定义,需要在jsp页面导入标签    1 ...

  3. Flask+ Angularjs 实例: 创建博客

    允许任何用户注册 允许注册的用户登录 允许登录的用户创建博客 允许在首页展示博客 允许登录的用户退 后端 Flask-RESTful - Flask 的 RESTful 扩展 Flask-SQLAlc ...

  4. 【HTML/XML 2】XML基础知识点总结

    导读:刚开始看到这个名的时候,还以为会和HTML一样呢,结果看完了资料里的视频,才发现是各有千秋.现在,就对XML的基础知识,做一个总结. 一.总体概述 XML(Extensible Markup L ...

  5. 刷题总结——竞赛得分(ssoj)

    题目: 题目描述 ZZH 在经历了无数次学科竞赛的失败以后,得到了一个真理:做一题就要对一题!但是要完全正确地做对一题是要花很多时间(包括调试时间),而竞赛的时间有限.所以开始做题之前最好先认真审题, ...

  6. Spring-IOC源码解读2-容器的初始化过程

    1. IOC容器的初始化过程:IOC容器的初始化由refresh()方法启动,这个启动包括:BeanDifinition的Resource定位,加载和注册三个过程.初始化的过程不包含Bean依赖注入的 ...

  7. 解决 IDEA 中src下xml等资源文件无法读取的问题

    该问题的实质是,idea对classpath的规定. 在eclipse中,把资源文件放在src文件夹下,是可以找到的: 但是在idea中,直接把资源文件放在src文件夹下,如果不进行设置,是不能被找到 ...

  8. Nk 1430 Divisors(因子数与质因数)

    Time Limit: 5000 ms    Memory Limit: 10000 kB   Total Submit : 432 (78 users)   Accepted Submit : 10 ...

  9. php——验证身份证是否合法的函数

    function is_idcard( $id ){ $id = strtoupper($id); $regx = "/(^\d{15}$)|(^\d{17}([0-9]|X)$)/&quo ...

  10. 使用注解开发springmvc

    1.导入jar包 commons-logging-1.2.jar spring-aop-4.3.6.RELEASE.jar spring-beans-4.3.6.RELEASE.jar spring- ...