Holding Bin-Laden Captive!

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

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:  1171 2152 2082 1709 2079
 
 
 
#include<stdio.h>
#include<string.h>
int c[],temp[];
int cost[]={,,};
int num[];
int main(){
while(scanf("%d%d%d",&num[],&num[],&num[])!=EOF){
if(num[]==&&num[]==&&num[]==)
break;
int total=num[]*+num[]*+num[]*;
memset(c,,sizeof(c));
memset(temp,,sizeof(temp));
for(int i=;i<=num[];i++)
c[i]=; for(int i=;i<;i++){
for(int j=;j<=total;j++){
for(int k=;k+j<=total&&k/cost[i]<=num[i];k+=cost[i])///此步应该特别注意,要保证k/cost[i]〈num[i] 即k的总值不能超过题里给出的范围
temp[k+j]+=c[j];
} for(int ii=;ii<=total;ii++){
c[ii]=temp[ii];
temp[ii]=;
}
}
for(int i=;i<=total+;i++)
if(!c[i]){
printf("%d\n",i);
break;
}
}
return ;
}

hdu 1085 给出数量限制的母函数问题 Holding Bin-Laden Captive!的更多相关文章

  1. HDU 1284 钱币兑换问题(普通型 数量无限的母函数)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1284 钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others)    ...

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

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

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

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

  5. 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), //展 ...

  6. hdu 1085 有num1个 1 ,num2个 2 ,num3个 5 (母函数)

    有num1个 1 ,num2个 2 ,num3个 5问它们不能组成的最小正整数是谁 样例的母函数 (1+X)(1+X2)(1+X5+X10+X15)展开后 X4的系数为0 Sample Input1 ...

  7. HDU - 1085 母函数

    年轻人的第一道母函数入门题 #include<bits/stdc++.h> using namespace std; const int maxn = 1000+2000+5000+1; ...

  8. HDU 1085 Holding Bin-Laden Captive!(母函数,或者找规律)

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

  9. hdu 1085(普通母函数)

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

随机推荐

  1. 1、SpringBoot+Mybatis整合------简单CRUD的实现

    编译工具:STS 代码下载链接:https://github.com/theIndoorTrain/SpringBoot_Mybatis01/commit/b757cd9bfa4e2de551b2e9 ...

  2. LOJ#515. 「LibreOJ β Round #2」贪心只能过样例(bitset)

    内存限制:256 MiB时间限制:1000 ms标准输入输出 题目类型:传统评测方式:文本比较 上传者: nzhtl1477 提交提交记录统计讨论测试数据   题目描述 一共有 nnn个数,第 iii ...

  3. Smartforms 设置纸张打印格式

    在sap做一个打印报表,要先设置一个纸张打印格式,下面以工厂中常用来打印的针孔纸为例,在sap设置该纸张的打印格式,以用于报表: 1.运行事务代码SPAD:选择工具栏上的[完全管理]按钮——>选 ...

  4. MySQL为何不建议使用null列

      Preface       Null is a special constraint of columns.The columns in table will be added null cons ...

  5. 浅谈PHP中的数组和JS中的数组

    最近在做前后端对接的时候,遇到一个问题,前端要求返回的数据格式是左边的,但是我通过json_encode返回到的数据格式是右边的   注意:数据格式从"[]"(数组)变成了&quo ...

  6. 微信小程序禁止下拉_解决小程序下拉出现空白的情况

    微信小程序禁止下拉 在微信小程序中,用力往下拉动,页面顶部会出现一段空白的地方. 产品的需求不太允许这么做,会影响用户体验,查看文档发现可以使用enablePullDownRefresh这属性来实现, ...

  7. 如何导入CSV数据 (python3.6.6区别于python2 环境)

    1.python2环境下 2.python3.6.6环境下 如果用python2环境下的代码,在python3.6.6环境下编译会出现以下问题: 错误(1): SyntaxError:Missing ...

  8. Ajax全解析

    什么是Ajax Ajax基本概念 Ajax(Asynchronous JavaScript and XML):翻译成中文就是异步的JavaScript和XML. 从功能上来看是一种在无需重新加载整个网 ...

  9. 493. Reverse Pairs

    // see more at https://www.youtube.com/watch?v=j68OXAMlTM4 // https://leetcode.com/problems/reverse- ...

  10. C语言进阶——循环语句07

    循环语句的基本工作方式: 通过条件表达式判定是否执行循环体 条件表达式遵循if语句表达式的原则 do,while,for的区别: do语句先执行后判断,循环体至少执行一次 while语句先判断后执行, ...