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. memcpy实现

    typedef unsigned int size_t; void * my_memcpy ( void *dest, const void *src, size_t num ) { void* re ...

  2. MapReduce编程基础

    MapReduce编程基础 1. WordCount示例及MapReduce程序框架 2.  MapReduce程序执行流程 3.  深入学习MapReduce编程(1) 4. 参考资料及代码下载 & ...

  3. Guava Files 源码分析(一)

    Files中的工厂 Files类中对InputStream, OutputStream以及Reader,Writer的操作封装了抽象工厂模式,抽象工厂是InputSupplier与OutputSupp ...

  4. leetcode笔记:Same Tree

    一. 题目描写叙述 Given two binary trees, write a function to check if they are equal or not. Two binary tre ...

  5. C#中属性PropertyInfo的使用

    昨天编程遇到一个问题两个类字段都是二十多个,其中有十多个是相同的,需要将一个类的字段赋值给另外一个类,开始的自己想手动的一个个去赋值,后来想来一下C#基础知识,用PropertyInfo就可以解决类似 ...

  6. Best Time to Buy and Sell Stock leetcode java

    题目: Say you have an array for which the ith element is the price of a given stock on day i. If you w ...

  7. Windows 8提升普通管理员权限为超级管理员权限以及激活超级管理员Administrator

    在Windows 8下运行某些操作时(比如删除一些文件或者更改某些系统设置时)系统会提示我们权限不够.须要Administrator账户的权限. 相信很多其它的使用者都会觉得自己当前使用的账户已经是系 ...

  8. 腾讯云兑现存储获取临时授权C#版

    腾讯官方没有提供C#版的,没办法自己根据java版改写了一个,这里面的坑花了我20多个小时,所以记录下 <%@ WebHandler Language="C#" Class= ...

  9. 分享几个.NET 下的计划任务组件

    Quartz http://www.quartz-scheduler.net/(现项目在使用,可以看我之前的文章) Hangfire http://hangfire.io/ Install-Packa ...

  10. eclipse 代码上传github 笔记

    第一步 先share project 如图所示  第二步 如果所示  第三步 点击 下面的create 然后点击完成  第四步提交  第五步: 第六步: