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. MFC中关于CListBox控件添加水平滚动条

    首先是设置listbox控件的属性  Horizontal Scroll设为TRUE: 然后添加函数到CUighurRecognitionDlg.cpp(在CUighurRecognitionDlg. ...

  2. vscode python code-runner 中文乱码解决

    https://www.cnblogs.com/zhaoshizi/p/9050768.html 这里我使用的是第二种方法

  3. joyoi1864 守卫者的挑战

    #include <algorithm> #include <iostream> #include <cstdio> using namespace std; in ...

  4. js 加密混淆

    没有找到合适的加密算法就用的以下方式 拿webpack打包一遍,再拿uglify压缩一遍,再拿eval加密一遍 1. webpack ./init.js ./webpack/bundle.js -p ...

  5. RHEL7网卡命名规则

    systemd 和 udev 引入了一种新的网络设备命名方式:一致网络设备命名(CONSISTENT NETWORK DEVICE NAMING).根据固件.拓扑.位置信息来设置固定名字,带来的好处是 ...

  6. RDDs基本操作、RDDs特性、KeyValue对RDDs、RDD依赖

    摘要:RDD是Spark中极为重要的数据抽象,这里总结RDD的概念,基本操作Transformation(转换)与Action,RDDs的特性,KeyValue对RDDs的Transformation ...

  7. BZOJ-1269 文本编辑器

    .... 这道题就是Noi原题嘛...虽然更容易写... 题意: 建立一个数据结构,并支持以下操作: Insert 区间插入有序序列:Delete 区间删除:Rotate 区间翻转:Get 单点查询 ...

  8. P1026 统计单词个数 (动态规划)

    题目描述 给出一个长度不超过200的由小写英文字母组成的字母串(约定;该字串以每行20个字母的方式输入,且保证每行一定为20个).要求将此字母串分成k份(1<k<=40),且每份中包含的单 ...

  9. P3146 [USACO16OPEN]248 (区间DP)

    题目描述  给定一个1*n的地图,在里面玩2048,每次可以合并相邻两个(数值范围1-40),问最大能合出多少.注意合并后的数值并非加倍而是+1,例如2与2合并后的数值为3. 这道题的思路: 状态: ...

  10. angular中ng-repeat去重

    [html] view plain copy print?在CODE上查看代码片派生到我的代码片 <div ng-app="myApp" ng-controller=&quo ...