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. HTTP Method 详细解读(`GET` `HEAD` `POST` `OPTIONS` `PUT` `DELETE` `TRACE` `CONNECT`)--转

    前言 HTTP Method的历史: HTTP 0.9 这个版本只有GET方法 HTTP 1.0 这个版本有GET HEAD POST这三个方法 HTTP 1.1 这个版本是当前版本,包含GET HE ...

  2. GPGPU::数学基础教程

    并行方向需要学习的数学知识 http://dev.gameres.com/Program/Visual/3D/GPGPU_math_Tutorial.html

  3. Subversion简介

    作为一名编程人员,SVN经常作为代码.项目的版本控制,殊不知SVN也可作为其他领域的版本控制,例如对文档.音频.视频等 . SVN可以看成一种文件系统,为了使工作人员提高工作效率,可以进行并行的工作, ...

  4. 知识总结和记录——Bootstrap

    官方地址:https://getbootstrap.com 中文地址:http://www.bootcss.com/ 使用V3版本的Bootstrap,下载的是用于生产环境的Bootstrap. 目录 ...

  5. JSPatch库, 一个Apple官方支持的实现在线更新iOS应用的库

    简介 项目主页: https://github.com/bang590/JSPatch 示例下载: https://github.com/ios122/ios122 JSPatch 可以让你用 Jav ...

  6. int ,long long 范围

    类型名称 字节数 取值范围signed char 1 -128-+127short int 2 -32768-+32767int 4 -2147483648-+2147483647(10位数 2^31 ...

  7. 洛谷P3611 [USACO17JAN]Cow Dance Show奶牛舞蹈

    题目描述 After several months of rehearsal, the cows are just about ready to put on their annual dance p ...

  8. mariadb源码编译安装及多实例

    准备文件源文件/app/mariadb-10.2.12.tar.gz cd /app/ tar xf mariadb-10.2.12.tar.gz cd  mariadb-10.2.12 mkdir ...

  9. spring开篇

    本文引用http://www.cnblogs.com/ityouknow/p/5292559.html spring简介: spring是一个开源框架,spring是于2003 年兴起的一个轻量级的J ...

  10. JAVA / MySql 编程——第八章 DAO 模式

    1.        数据持久化:将程序中的数据在瞬时状态和持久状态间转换的机制即为数据持久化: 2.        持久化的实现方式:数据库.普通文件.XML文件: 3.        JDBC封装: ...