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 ...
随机推荐
- CUDA 纹理内存
原文链接 1.概述 纹理存储器中的数据以一维.二维或者三维数组的形式存储在显存中,可以通过缓存加速访问,并且可以声明大小比常数存储器要大的多. 在kernel中访问纹理存储器的操作称为纹理拾取(tex ...
- PEP8 常用规范
PEP8 常用规范 完整的规范移步这里两个传送门 pep8规范 官方文档:https://www.python.org/dev/peps/pep-0008/ PEP8中文翻译:http://www.c ...
- Nginx+php+mysql+wordpress搭建自己的博客站点
服务器环境要求Centos 6 或以上版本(由于我们的目标是半小时内搭建好,那就选简单yum安装)MySQL 5或更新版本Nginx 1或更新版本PHP 5 或更新版本 php-fpm 5或更新版本 ...
- OpenStack Grizzly版本部署(离线)
参考原版地址:https://github.com/mseknibilel/OpenStack-Grizzly-Install-Guide 图转自原版地址 部署拓扑: 部署环境:vmware stat ...
- 判断移动端和pc端最简单的方法
<!DOCTYPE html><html><head> <title></title> <script type="text ...
- Open source cryptocurrency exchange
Peatio: https://github.com/peatio/peatio ViaBTC: https://github.com/viabtc/viabtc_exchange_server
- 011---Djang的cookie和session
-------------------------------------------------------------cookie与session------------------------- ...
- JAVA-数组或集合
哈哈,今天我们来讲解一下有关于一些数组 或者是集合的知识点 1.ArrayList,LinkedList,Vector的区别 ArrayList,LinkedList,Vector都是实现List接口 ...
- Android+Handler+Thread 那些事儿
前言,才开始学安卓十几天,不料被线程挡住了前进的步伐,因为之前操作系统课程并没有认真听老师讲课,导致现在理解这些抽象的东西有些小困难.没关系,苦学之路,总会碰到坎坷,这里也给那些迷失在Android之 ...
- python time时间模块
在Python中,通常有这三种方式来表示时间:时间戳.元组(struct_time).格式化的时间字符串 (1)时间戳(timestamp) :通常来说,时间戳表示的是从1970年1月1日00:00: ...