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): 15384 Accepted Submission(s): 6892
“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!
1 1 3 0 0 0
4 仍旧是母函数水过。 题意:有3种面值的硬币{1,2,5} 如今给出这3种硬币的个数,求最小不能组成的面值。 。 暴力生成 a[]数组扫一遍第一个为0的就是最小不能组成的面值 #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cctype> #include <cmath> #include <cstdlib> #include <vector> #include <queue> #include <set> #include <map> #include <list> #define maxn 100100 #define ll long long #define INF 0x3f3f3f3f #define pp pair<int,int> using namespace std; int a[maxn],b[maxn],v[3]={1,2,5},p,n[3]; void solve() { p=n[0]+n[1]*2+n[2]*5; memset(a,0,sizeof(a)); a[0]=1; for(int i=0;i<3;i++) { memset(b,0,sizeof(b)); for(int j=0;j<=n[i]&&j*v[i]<=p;j++) for(int k=0;k+j*v[i]<=p;k++) b[k+j*v[i]]+=a[k]; memcpy(a,b,sizeof(b)); } int ans; for(ans=0;ans<=p;++ans) if(a[ans]==0)break; printf("%d\n",ans); } int main() { while(~scanf("%d%d%d",&n[0],&n[1],&n[2])) { if(!n[0]&&!n[1]&&!n[2])break; solve(); } return 0;}
版权声明:本文博主原创文章,博客,未经同意不得转载。
HDU 1085-Holding Bin-Laden Captive!(生成功能)的更多相关文章
- 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!(母函数,或者找规律)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDU 1085 Holding Bin-Laden Captive!(DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1085 解题报告:有1,2,5三种面值的硬币,这三种硬币的数量分别是num_1,num_2,num_5, ...
- 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!
Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for ...
- 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的硬币若干,问你最小的不能组成的币值为多少. 解法:写出生成函数: 然后求每项的系数即可. 因为三种硬币最多1000枚,1*1000+2*1000+5*1000=8 ...
- 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), //展 ...
- 代码生成工具Database2Sharp中增加视图的代码生成以及主从表界面生成功能
在代码生成工具的各种功能规划中,我们一向以客户的需求作为驱动,因此也会根据需要增加一些特殊的功能或者处理.在实际的开发中,虽然我们一般以具体的表进行具体业务开发,但是有些客户提出有时候视图开发也是很常 ...
- Taurus.MVC 2.3 开源发布:增强属性Require验证功能,自带WebAPI文档生成功能
背景: 上周,把 Taurus.MVC 在 Linux (CentOS7) 上部署任务完成后. 也不知怎么的,忽然就想给框架集成一下WebAPI文档功能,所以就动手了. 以为一天能搞完,结果,好几天过 ...
随机推荐
- Inno Setup打包添加和去除管理员权限
原文:Inno Setup打包添加和去除管理员权限 添加管理员权限 1.在[Setup]节点添加 PrivilegesRequired=admin 2.进入安装目录,找到文件SetupLdr.e32, ...
- 嵌入式Linux下BOA网页server的移植
**************************************************************************************************** ...
- Cordova CLI源码分析(二)——package.json
每个包需要在其顶层目录下包含一个package.json文件,该文件不仅是包的说明,也影响npm安装包时的配置选项 更多参数详见参考文档https://npmjs.org/doc/json.html ...
- Cordova CLI源码分析(四)——创建工程
在第一篇分析我们曾经举例,创建一个新工程, cordova create hello hellotest com.xxx.hellotest cli.js文件分析命令行参数后,会走到 else if ...
- 站点接入QQ登录
首先引入授权js文件 <script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/op ...
- APUE学习--网络编程(3)
本篇文章介绍TCP通信. 上文提到传输层的两个协议TCP和UDP,UDP是无连接的已经介绍过,TCP是面向连接的,阐述建立连接和断开连接前先来看下TCP报文头的结构. 报文头在linux的定义在/us ...
- include设置属性在relativelayout布局中无效
转自:http://4265337.blog.163.com/blog/static/195375820127935731114/ 再来说一个在使用这两个标签时最容易出现的问题. 经常会有同学在Rel ...
- Objective-C之成魔之路【9-类构造方法和成员变量作用域、以及变量】
郝萌主倾心贡献,尊重作者的劳动成果.请勿转载. 假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额任意,重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 构造方法 ...
- springMVC整合JAXB
一.背景 由于项目中要用到将Java对象转为xml返回给调用者.选择使用JAXB,由于它是JDK自带的.不须要引入其它Jar包 它提供了高速而简便的方法将xml和对象互转的方法. 二.重要Class和 ...
- VirtualBox安装ubuntu14.04和文件共享
因为机器的VMware使用很卡,占用更多的内存,所以我想,以取代VirtualBox.已安装ubuntu14.04使用与VMware在相同的. VirtualBox下载链接:https://www.v ...