Holding Bin-Laden Captive!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 15501    Accepted Submission(s): 6951

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
/*母函数应用。

不是太理解。模仿模板。记住代码= =
*/
#include<stdio.h>
int a[10000],s[10000];
int main()
{
int x,y,z,max;
int i,j,k;
while(scanf("%d%d%d",&x,&y,&z)&&(x||y||z))
{
max=x+y*2+z*5;
for(i=0;i<=max;i++)
{
a[i]=0;
s[i]=0;
}
for(i=0;i<=x;i++)
s[i]=1;
for(i=0;i<=x;i++)
{
for(j=0;j<=y*2;j+=2)
{
a[i+j]+=s[i];
}
}
for(i=0;i<=x+y*2;i++)
{
s[i]=a[i];
a[i]=0;
}
for(i=0;i<=x+y*2;i++)
{
for(j=0;j<=z*5;j+=5)
{
a[i+j]+=s[i];
}
}
for(i=0;i<=max;i++)
{
s[i]=a[i];
a[i]=0;
}
for(i=0;i<=max;i++)
{
if(s[i]==0)
{
printf("%d\n",i);
break;
}
}
if(i==max+1)
printf("%d\n",i);
}
return 0;
}

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

  1. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  2. 杭电ACM题单

    杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最 ...

  3. 杭电acm习题分类

    专注于C语言编程 C Programming Practice Problems (Programming Challenges) 杭电ACM题目分类 基础题:1000.1001.1004.1005. ...

  4. 杭电OJ——1198 Farm Irrigation (并查集)

    畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可 ...

  5. 杭电acm 1033题

    Problem Description For products that are wrapped in small packings it is necessary that the sheet o ...

  6. acm入门 杭电1001题 有关溢出的考虑

    最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...

  7. 杭电acm 1002 大数模板(一)

    从杭电第一题开始A,发现做到1002就不会了,经过几天时间终于A出来了,顺便整理了一下关于大数的东西 其实这是刘汝佳老师在<算法竞赛 经典入门 第二版> 中所讲的模板,代码原封不动写上的, ...

  8. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

  9. C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~

    暑假集训虽然很快乐,偶尔也会比较枯燥,,这个时候就需要自娱自乐... 然后看hdu的排行榜发现,除了一些是虚拟测评机的账号以外,有几个都是AC自动机器人 然后发现有一位作者是用网页填表然后按钮模拟,, ...

随机推荐

  1. Visual Studio的SDK配置

    Visual Studio的SDK Visual Studio 6.0自带的SDK是1998年的,目录为C:\Program Files\Microsoft Visual Studio\VC98\,这 ...

  2. win7下不能收到窗口hook消息的问题

    win7下由于UIPI的限制, 高权限进程无法收到底权限进程发来的消息, 因此对窗口消息hook时无法接收到消息,解决办法是在调用SetWindowsHookEx之前先调用ChangeWindowMe ...

  3. 九度OJ 1179 阶乘(模拟)

    题目1179:阶乘 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4526 解决:1315 题目描写叙述: 输入n, 求y1=1!+3!+...m!(m是小于等于n的最大奇数) y2=2! ...

  4. UVA 1386 - Cellular Automaton(循环矩阵)

    UVA 1386 - Cellular Automaton option=com_onlinejudge&Itemid=8&page=show_problem&category ...

  5. 访问项目时,不能自动加载index.php文件

    1.修改配置文件D:\lamp\apache\conf\httpd.conf加上DirectoryIndex index.hmtl index.php <IfModule !mpm_netwar ...

  6. NET Core 中的依赖注入

    NET Core 中的依赖注入 [共7篇] 一.控制反转(IoC) ASP.NET Core在启动以及后续针对每个请求的处理过程中的各个环节都需要相应的组件提供相应的服务,为了方便对这些组件进行定制, ...

  7. win7下怎样设置putty免用户名密码登陆

    putty是一款好用的远程登录linux服务器软件,但每次输入用户名密码毕竟有些烦人,这里教你免用户名密码登陆.   工具/原料 putty 方法/步骤   去百度下载putty,小巧易用,仅有0.5 ...

  8. Github干货系列:C++资源集合-

    Awesome CPP,这又是一个 Awesome XXX 系列的资源整理,由 fffaraz 发起和维护.内容包括:标准库.Web应用框架.人工智能.数据库.图片处理.机器学习.日志.代码分析等. ...

  9. TestComplete实测Flex

    1.TestComplete提供了已经编译好的Flex界面,可以直接使用: http://support.smartbear.com/samples/testcomplete9/flex/orders ...

  10. 深入探讨:LBS是一种工具而非一种模式

    移动互联网的快速发展,带动着移动互联网应用的不断创新.从2010起,LBS的概念就在中国迅速兴起,但到了2011年底提供LBS服务的企业从最多50家已经降至仅剩15家.投行在看好移动互联网的同时又对L ...