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. 《深入理解C#(第3版)》

    <深入理解C#(第3版)> 基本信息 原书名:C# in depth 作者: (英)Jon Skeet 译者: 姚琪琳 丛书名: 图灵程序设计丛书 出版社:人民邮电出版社 ISBN:978 ...

  2. 【BZOJ】【1091】【SCOI2003】切割多边形

    计算几何+枚举 我比较傻逼……一开始想了个贪心,就是这样:

  3. 深入理解VUE样式style层次分析

    刚开始使用vue的时候容易被里面的样式搞懵: 样式可以在main.js中引入,在模块js文件中引入,在组件中的style标签引入,在组件中的script标签引入,还可以在index.html的body ...

  4. nGrinder对监控机器收集自定义数据及源码分析

    转载:https://blog.csdn.net/neven7/article/details/50782451 0.背景 性能测试工具nGrinder支持在无需修改源码的情况下,对目标服务器收集自定 ...

  5. UE自动将关键字首字母大写怎么办

    对于某些关键字,UE会自动将首字母大写. 只要选中这些文字,右键选择"格式",转为小写字母即可.

  6. cybergarage-upnp

    官网: http://www.cybergarage.org/twiki/bin/view/Main/UPnPFramework Open Source Frameworks for UPnP Cyb ...

  7. CATransition 动画处理视图切换

    一:引入包和头文件:   需要在frameworks中添加QuartzCore.framework 在接口程序中加上头文件   #import <QuartzCore/QuartzCore.h& ...

  8. Nhibernate Criteria 多个or条件查询

    sql: select * from table t where (t.name like '%张三%' or t.schoolName like '%张三%' or t.cityname like ...

  9. 算法笔记_187:历届试题 网络寻路(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 X 国的一个网络使用若干条线路连接若干个节点.节点间的通信是双向的.某重要数据包,为了安全起见,必须恰好被转发两次到达目的地.该包可能在任 ...

  10. How to Analyze Java Thread Dumps

    When there is an obstacle, or when a Java based Web application is running much slower than expected ...