Holding Bin-Laden Captive!

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

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
 
 无疑是一道,母函数题.....(有关母函数的详细,请查看百度百科,在此就不做详细的说明了).
 这道题的方法为:g(x)=(1+x^1+x^2+......+x^num1)*x^2(1+x^1+....+x^num2)*x^5(1+x^1+.....+x^num3);
 其系数为0的即为所求:  所以关键是如何表达上面的式子.....一般采取的方法为先两两相乘...然后用得到结果与第三方相乘即可....
  代码如下:

 #include<iostream>
#include<cstring>
using namespace std;
const int maxn= ;
int ratio[maxn], //系数
index[maxn]; //指数 int main()
{
int num1,num2,num3,i,j;
bool judge;
while(cin>>num1>>num2>>num3,num1+num2+num3)
{
memset(ratio,,sizeof ratio);
memset(index,,sizeof index);
for(i=;i<=num1;i++)
{
ratio[i]=;
for(j=;j<=num2;j++)
{
index[*j+i]+=ratio[i];
}
}
for(i=;i<=num1+*num2;i++)
{
ratio[i]=index[i];
index[i]=;
}
for(i=;i<=num1+*num2;i++)
{
for(j=;j<=num3;j++)
{
index[j*+i]=ratio[i];
}
}
judge=true;
for(i=;i<=num1+*num2+*num3;i++)
{
if(!index[i])
{
judge=false;
printf("%d\n",i);
break;
}
}
if(judge)
printf("%d\n",num1+*num2+*num3+);
}
return ;
}

HDUOJ-----1085Holding Bin-Laden Captive!的更多相关文章

  1. 用主题模型可视化分析911新闻(Python版)

    本文由 伯乐在线 - 东狗 翻译,toolate 校稿.未经许可,禁止转载!英文出处:blog.dominodatalab.com.欢迎加入翻译小组. 本文介绍一个将911袭击及后续影响相关新闻文章的 ...

  2. How do I learn mathematics for machine learning?

    https://www.quora.com/How-do-I-learn-mathematics-for-machine-learning   How do I learn mathematics f ...

  3. Labeled Faces in the Wild 人脸识别数据集 部分测试数据

    development test set Note: images displayed are original (non-aligned/funneled) images. match pairs ...

  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. HDOJ 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! (母函数)

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

  7. Holding Bin-Laden Captive!(母函数)

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

  8. Holding Bin-Laden Captive!(杭电1085)(母函数)

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

  9. Holding Bin-Laden Captive!(1.多重背包 2.母函数)

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

  10. HDUOJ--Holding Bin-Laden Captive!

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

随机推荐

  1. 采用Operator-sdk轻松将helm chart转为Operator

    去年就接触Operator,从Oracle发布的WebLogic Operator到mySQL Operator,构建的源码一大堆,但感觉一直缺少合适的开发框架能够避免复杂性快速生成, 随着技术的日益 ...

  2. OpenCV学习(39) OpenCV中的LBP图像

    本章我们学习LBP图像的原理和使用,因为接下来教程我们要使用LBP图像的直方图来进行脸部识别. 参考资料: http://docs.opencv.org/modules/contrib/doc/fac ...

  3. iOS开发-Xcode入门ObjC程序

    元旦三天假跟妹子冷战一天半,剩下的半天觉得无聊,可以写点东西,折腾了下xCode 6.1,虽然iPhone6比较丑,但是不影响IOS在高端机上面的地位,ObjC是扩充C的面向对象编程语言.主要使用于M ...

  4. js实现trim() JS去掉首尾空格 JS去掉两头空格

    function trimStr(str){ return str.replace(/(^\s*)|(\s*$)/g,""); } 用的时候就是直接 var 变量=trimStr( ...

  5. MongoDB学习笔记(五)--复制集 && sharding分片

    主从复制                                                                                       主从节点开启 主节 ...

  6. [置顶] 利用Global.asax的Application_BeginRequest 实现url 重写 无后缀

    利用Global.asax的Application_BeginRequest 实现url 重写 无后缀 <%@ Application Language="C#" %> ...

  7. RUP---统一软件开发过程

    更详细的见:http://www.ibm.com/developerworks/cn/rational/r-rupbp/ 本文引用:http://baike.baidu.com/view/223583 ...

  8. JSON字符串转换为Map

    本文是利用阿里巴巴封装的FastJSON来转换json字符串的.例子如下: package com.zkn.newlearn.json; import com.alibaba.fastjson.JSO ...

  9. C#.NET常见问题(FAQ)-如何捕捉窗体关闭的事件,弹窗确认是否退出

    首先定位到窗体的FormClosing事件中,写关闭之前要执行的方法名称   一般只需要添加下面的代码即可实现窗体关闭的时候提示是否确认退出 //捕捉窗体Close事件,关闭窗口时提示 if (Mes ...

  10. HDU 1199 &amp;&amp; ZOJ 2301 线段树离散化

    一段长度未知的线段.一种操作:a b c ,表示区间[a,b]涂为颜色C,w代表白色,b代表黑色,问终于的最长连续白色段,输出起始位置和终止位置 离散化处理.和寻常的离散化不同,须要把点化成线段.左闭 ...