hdu 1085 给出数量限制的母函数问题 Holding Bin-Laden Captive!
Holding Bin-Laden Captive!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 17256 Accepted Submission(s): 7734
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!
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.
0 0 0
#include<stdio.h>
#include<string.h>
int c[],temp[];
int cost[]={,,};
int num[];
int main(){
while(scanf("%d%d%d",&num[],&num[],&num[])!=EOF){
if(num[]==&&num[]==&&num[]==)
break;
int total=num[]*+num[]*+num[]*;
memset(c,,sizeof(c));
memset(temp,,sizeof(temp));
for(int i=;i<=num[];i++)
c[i]=; for(int i=;i<;i++){
for(int j=;j<=total;j++){
for(int k=;k+j<=total&&k/cost[i]<=num[i];k+=cost[i])///此步应该特别注意,要保证k/cost[i]〈num[i] 即k的总值不能超过题里给出的范围
temp[k+j]+=c[j];
} for(int ii=;ii<=total;ii++){
c[ii]=temp[ii];
temp[ii]=;
}
}
for(int i=;i<=total+;i++)
if(!c[i]){
printf("%d\n",i);
break;
}
}
return ;
}
hdu 1085 给出数量限制的母函数问题 Holding Bin-Laden Captive!的更多相关文章
- HDU 1284 钱币兑换问题(普通型 数量无限的母函数)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1284 钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others) ...
- HDOJ/HDU 1085 Holding Bin-Laden Captive!(非母函数求解)
Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for ...
- HDU 1085 Holding Bin-Laden Captive! (母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDU 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)
题意: 有面值分别为1.2.5的硬币,分别有num_1.num_2.num_5个,问不能组成的最小面值是多少?(0<=每种硬币个数<=1000,组成的面值>0) 思路: 母函数解决. ...
- hdu 1085 Holding Bin-Laden Captive! (母函数)
//给你面值为1,2,5的三种硬币固定的数目,求不能凑出的最小钱数 //G(x)=(1+x+...+x^num1)(1+x^2+...+x^2num2)(1+x^5+,,,+x^5num3), //展 ...
- hdu 1085 有num1个 1 ,num2个 2 ,num3个 5 (母函数)
有num1个 1 ,num2个 2 ,num3个 5问它们不能组成的最小正整数是谁 样例的母函数 (1+X)(1+X2)(1+X5+X10+X15)展开后 X4的系数为0 Sample Input1 ...
- HDU - 1085 母函数
年轻人的第一道母函数入门题 #include<bits/stdc++.h> using namespace std; const int maxn = 1000+2000+5000+1; ...
- HDU 1085 Holding Bin-Laden Captive!(母函数,或者找规律)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- hdu 1085(普通母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
随机推荐
- OC#import和#include的异同
1.#import和#include相同1.1都可以用在OC程序中起到导入文件的作用1.2同样的 包含系统文件都是<>,是包本地文件都用""例如:系统文件#import ...
- 深入理解 SVG 系列(一) —— SVG 基础
来源:https://segmentfault.com/a/1190000015652209 本系列文章分为三个部分: 第一部分是 SVG 基础. 主要讲 SVG 的一些基础知识,包括 SVG 基本元 ...
- finddler的安装与设置
这是抓取手机包的设置 过滤 新安装的,可能还需要证书问题
- MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES)
1.先停止mysql服务 2.进入mysql的安装路径,找到并打开my.ini文件,找到[mysqld],在该行下面添加 skip_grant_tables,也就是通知mysql,在登陆的时候跳过密码 ...
- Linux自带mariadb卸载
MySQL安装过程中报错: dpkg: regarding mysql-community-server_5.6.39-1debian9_i386.deb containing mysql-commu ...
- 解决php文字及图片显示乱码的问题
我们在学习PHP的过程中,想必有不少新手朋友们都遇到过乱码的问题,解决乱码问题不仅是小白们必须掌握的基础知识点,也是最为常见的PHP面试题之一.下面就结合简单代码示例给大家总结介绍下,PHP遇到乱码时 ...
- Shell学习——数值运算
在Bash shell中,可以利用let.(( )).[]执行基本的算术操作,在高级操作时,使用expr和bc两个工具1.let[root@client02 ~]# no1=4[root@client ...
- JSON后台处理特殊字符方法,在JSONArray.fromObject转换时处理
/** * 替换一个字符串中的某些指定字符 * @param strData String 原始字符串 * @param regex String 要替换的字符串 * @param replaceme ...
- python学习之数据类型与运算符号
python版本:3.6 python编辑器:pycharm 最新版本 整理成代码如下: #!/usr/bin/env python #-*- coding: utf-8 -*- # 数学操作符 pr ...
- 数据分析处理库Pandas——对象操作
Series结构 索引 修改 旧数据赋值给新数据,旧数据不变. 对某一数值进行修改,可以选择保留修改前或修改后的数值. 替换索引 修改某一个索引 添加 在数据1后添加数据2,数据1不改变. 添加一个数 ...