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

母函数,注意的是每一个式子不是无限的,所以要加上一个cot<=b和cot<=c表示一个式子只有b,c项,不要超过了
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int c1[],c2[];
int main()
{
int a,b,c;
int num;
while(cin>>a>>b>>c)
{
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2));
if(a==&&b==&&c==) break;
for(int i=;i<=a;i++)
{
c1[i]=;
}
num = a+*b+*c;
int k,cot;
for(int j=;j<=num;j++)
{
for(k=,cot=;k+j<=num&&cot<=b;k+=,cot++)
{
c2[j+k]+=c1[j];
}
}
for(int j=; j<=num; j++)
{
c1[j] = c2[j];
c2[j] =;
}
for(int j=; j<=num; j++)
{
for(k=,cot=; k+j<=num&&cot<=c; k+=,cot++)
{
c2[j+k]+=c1[j];
}
}
for(int j=; j<=num; j++)
{
c1[j] = c2[j];
c2[j] =;
}
int i;
for(i=;;i++)
{
if(!c1[i])
{
break;
}
}
cout<<i<<endl;
}
return ;
}

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

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

    简单的母函数应用. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstrin ...

  2. hdu1085 Holding Bin-Laden Captive!【生成函数】

    列出生成函数的多项式之后暴力乘即可 #include<iostream> #include<cstdio> #include<cstring> using name ...

  3. A过的题目

    1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...

  4. 缓冲区溢出利用——捕获eip的傻瓜式指南

    [译文] 摘要:为一个简单的有漏洞程序写一个简单的缓冲区溢出EXP,聚焦于遇到的问题和关键性的教训,提供详细而彻底的描述 内容表:1. I pity the fool, who can't smash ...

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

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

  6. 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 ...

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

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

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

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

随机推荐

  1. 超详细的Maven使用教程

    原文:  http://blog.csdn.net/u010425776/article/details/52027706 主题 Maven 什么是Maven? 如今我们构建一个项目需要用到很多第三方 ...

  2. 探索Web Office Apps服务

    老样子,先放几个官链: WOA部署规划:http://technet.microsoft.com/zh-cn/library/jj219435(v=office.15).aspx 拓扑规划:http: ...

  3. Solr搜索的排序打分规则探讨

    使用Solr搭建搜索引擎很容易,但是如何制定合理的打分规则(boost)做排序却是一个很头痛的事情.Solr本身的排序打分规则是继承自Lucene的文本相关度的打分即boost,这一套算法对于通用的提 ...

  4. NCBI下载SRA数据

    从NCBI下载数据本来是一件很简单的事情,但是今天碰到几个坑: 1.paper里没有提供SRA数据号.也没有提供路径: 2.不知道文件在ftp的地址,不能直接用wget下载 所以通过在NCBI官网,直 ...

  5. vue 之 箭头函数与对象的单体模式

    箭头函数 基本语法: ES6允许使用“箭头”(=>)定义函数 var f = a = > a //等同于 var f = function(a){ return a; } 如果箭头函数不需 ...

  6. Umbraco 中获取一个media item的文件路径 file path

    我们要使用UmbracoHelper, 这里就需要用到我们在之前的blog里面写的UmbracoContext 参看这个blog     https://www.cnblogs.com/wphl-27 ...

  7. 20169219《Linux内核原理与分析》第八周作业

    网易云课堂学习 task_struct数据结构 struct task_struct { volatile long state;进程状态 void *stack; 堆栈 pid_t pid; 进程标 ...

  8. JetBrains WebStorm 如何从GitHub上克隆的代码

    工作中经常会遇到要从GitHub上拉代码,详细操作记录如下: 绑定账号 1.File->Settings->Version Control->Github 成功后会出现下面的这个账户 ...

  9. 利用python下载视频

    我们知道,有些网页上的视频,没有下载的按钮,并且有些视频需要付费下载,很多同学因此很苦恼.不怕,有问题找我,我试试用程序员的方式通俗易懂教会大家. 1.你先下载一个Python,不会下载的同学可以看这 ...

  10. ubuntu - 如何搜索文件?

    1.whereis 文件名 特点:快速,但是是模糊查找,例如 找 #whereis mysql 它会把mysql,mysql.ini,mysql.*所在的目录都找出来.我一般的查找都用这条命令. 2. ...