Holding Bin-Laden Captive!

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

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<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int c1[];
int c2[];
int c3[]; int main()
{
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c)!=EOF&&(a||b||c))
{
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2));
memset(c3,,sizeof(c3));
for(int i=; i<=a; i++)
c1[i]=;
for(int i=; i<=a; i++)
for(int j=; j<=*b; j+=)
c2[i+j]+=c1[i]; for(int i=;i<=a+b*;i++)
{
c1[i]=c2[i];
c2[i]=;
}
for(int i=; i<=(a*)+(b*); i++)
for(int j=; j<=*c; j+=)
c2[i+j]+=c1[i];
for(int i=;i<=a+b*+c*;i++)
c1[i]=c2[i];
/*for(int i=0;i<=a+2*b+5*c;i++)
cout<<c1[i]<<endl;
cout<<endl;*/
for(int i=;i<=a+*b+*c+;i++)
if(c1[i]==)
{
printf("%d\n",i);
break;
}
}
return ;
}

HDU_1085_Holding Bin-Laden Captive!_母函数的更多相关文章

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

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

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

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

  3. HDOJ 1085 Holding Bin-Laden Captive! (母函数)

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

  4. HDOJ/HDU 1085 Holding Bin-Laden Captive!(非母函数求解)

    Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for ...

  5. hdu 2079 选课时间_母函数

    题意:需要学够n学分,有k个情况(x学分,y个相同学分的课) 解法:套母函数模板 #include <iostream> #include<cstdio> using name ...

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

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

  7. Bash 中的 _ 是不是环境变量

    首先,我们想到的会是 export(等价于 declare -x)命令: $ export | grep 'declare -x _=' 没有找到,那么结论就是 _ 不是环境变量?当然没那么简单,否则 ...

  8. python_login输入三次错误密码锁定密码_密码不允许为空

    #!/usr/bin/env python #_*_coding:utf-8_*_ #by anthor zhangxiaoyu 2017-01-10 import getpass import os ...

  9. Python-老男孩-01_基础_文件IO_函数_yield_三元_常用内置函数_反射_random_md5_序列化_正则表达式_time

    Python2.7 缩进统一: 约定  常量 大写 , 变量  小写 判断一个变量在内存中的地址,也能看出是不是一个值 id()函数 >>> x = 'abc' >>&g ...

随机推荐

  1. 第3章 ES文档和故障处理

    第3章 ES文档和故障处理 一.ES网络配置表 ES网络配置表是ES的硬件和软件组成的列表.ES网络配置常包括以下项目: 分级 项目 杂项信息 系统名.系统厂商/型号.CPU速率.RAM.存储器.系统 ...

  2. Flex 绘制圆形并填充图片

    注意:Ellipse 绘制椭圆,当width = height 时 则绘制圆形. BitmapFill:填充图片 <s:Group id="gpimgUser" width= ...

  3. Windows 文件夹修改为exe的原理和解决办法

    有关文件夹后缀改为exe的病毒 该病毒之前出现过,不过没多长时间便消失了,最新的这个应该是变种,下面解决一下该病毒在移动存储设备中的问题: 该病毒并不具备能够将文件夹改为文件的能力,只是将原有文件夹全 ...

  4. java dom4j 读写XML

    <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Config id ...

  5. [Codeforces Round49F] Session in BSU

    [题目链接] http://codeforces.com/contest/1027/problem/F [算法] 二分图匹配 [代码] #include<bits/stdc++.h> #p ...

  6. ref 和out的区别

    在C#语言中,参数的传递有两种,一种是值传递,一种是引用传递.ref与out这两种方式都属于引用传递,只是他们的用法稍有不同.下面看几个例子 使用ref的例子 class test { static ...

  7. 查看mysql是否安装成功和mysql的版本信息

    转自:https://blog.csdn.net/hellocsz/article/details/81241204 使用快捷键win+R打开 进入mysql的安装目录下的\bin(本人安装路劲为E: ...

  8. B. Trees in a Row(cf)

    B. Trees in a Row time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  9. 互斥的数(hash)

    1553 互斥的数  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold     题目描述 Description 有这样的一个集合,集合中的元素个数由给定的N决定, ...

  10. go 成长路上的坑(1)

    一.先来看一段代码 package main import "fmt" type X struct{} func (x *X) test(){ println("h1&q ...