Holding Bin-Laden Captive!

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

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
 
 #include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int maxn=;
const int valu[]={,,,};
int c1[maxn],c2[maxn];
int a,b,c; void isOK()
{
int t[];
t[]=;t[]=a;t[]=b;t[]=c;
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2));
int n=*t[]+*t[]+*t[];//最大的项数
for(int i=;i<=a;i++)
{
c1[i]=;
}
for(int i=;i<=;i++)//层数的限制
{
for(int j=;j<=n;j++)
{
for(int k=;k+j<=n&&k<=valu[i]*t[i];k+=valu[i])//个数的限制
{
c2[k+j]+=c1[j];
}
}
for(int j=;j<=n;j++)
{
c1[j]=c2[j]; c2[j]=;
}
} for(int i=;i<=n+;i++)
{
if(c1[i]==)
{
printf("%d\n",i);
break;
}
}
} int main()
{
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
if(a==&&b==c&&c==) break;
isOK();
}
return ;
}

HDOJ 1085 Holding Bin-Laden Captive! (母函数)的更多相关文章

  1. HDOJ 1085 Holding Bin-Laden Captive!

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

  2. 【HDOJ 1085】数学问题,母函数

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

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

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

  4. HDU 1085 Holding Bin-Laden Captive! (母函数)

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

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

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

  6. HDU 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)

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

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

  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!(DP)

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

随机推荐

  1. php网页,想弹出对话框, 消息框 简单代码

    php网页,想弹出对话框, 消息框 简单代码 <?php echo "<script language=\"JavaScript\">alert(\&q ...

  2. WIN8+VS2013编写发布WCF之三(调用)

    在文二中部署成功后就可以在客户端程序中使用服务了...使用服务的过程总是这么酣畅淋漓.当然,对应文二中的三种部署方式,我也会在此描述三种使用方式,一一对应. 都是新建个程序了,然后开始介绍. 一.VS ...

  3. static 与 final 修饰符

    A) 用static(静态)修饰属性:一个类生成了N个对象,这些对象会共同使用一份静态的成员变量.一个对象对这个成员变量进行修改,其他对象的该成员变量的值也会随之变化. B) 我们可以通过 类名.成员 ...

  4. NOJ1008-第几天

    第几天 时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte总提交 : 2701            测试通过 : 800  ...

  5. hdu 2544 最短路

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2544 最短路 Description 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shi ...

  6. Android HTTP session && cookie

    HTTP协议与状态保持HTTP协议本身是无状态的,这与HTTP协议本来的目的是相符的,客户端只需要简单的向服务器请求下载某些文件,无论是客户端还是服务器都没有必要纪录彼此过去的行为,每一次请求之间都是 ...

  7. JavaScript高级程序设计之函数

    函数实际上是对象,每个函数都是Function类型的实例. 函数是引用类型. 函数名实际上是一个指向函数对象的指针,不会与某个函数绑定. // 这种写法更能表达函数的本质 var sum = func ...

  8. metaq

    MetaQ(全称Metamorphosis)是一个高性能.高可用.可扩展的分布式消息中间件,思路起源于LinkedIn的Kafka,但并不是Kafka的一个Copy.MetaQ具有消息存储顺序写.吞吐 ...

  9. python的小爬虫的基本写法

    1.最基本的抓站 import urllib2 content = urllib2.urlopen('http://XXXX').read() 2.使用代理服务器 这在某些情况下比较有用,比如IP被封 ...

  10. OC开发中运用到的枚举

      一  常见枚举的定义: typedef enum { LOGIN_SUCCESS, USER_NAME, USER_PASSWORD, OLD_LAT, OLD_LNG }FIELD_SAVED; ...