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),
//展开,系数不为0的数都是能够由硬币组合出来的。
# include <algorithm>
# include <string.h>
# include <stdio.h>
# include <iostream>
using namespace std;
int main()
{
int i,j,k,max1;
int c1[8100],c2[8100],a[10];
while(~scanf("%d%d%d",&a[1],&a[2],&a[5]),a[1]+a[2]+a[5])
{
max1=a[1]+a[2]*2+a[5]*5;
for(i=0;i<=8100;i++)
{
c1[i]=0;
c2[i]=0;
}
for(i=0;i<=a[1];i++)//第一种硬币
c1[i]=1;
for(i=2;i<=5;i+=3)
{
for(j=0;j<=8100;j++)
{
for(k=0;k*i+j<=8100&&k<=a[i];k++)
{
c2[j+k*i]+=c1[j];
}
}
for(j=0;j<=8100;j++)
{
c1[j]=c2[j];
c2[j]=0;
}
}
for(i=1;i<=8100;i++)
if(c1[i]==0)
{
printf("%d\n",i);
break;
} }
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 ...
- 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! 活捉本拉登(普通型母函数)
题意: 有面值分别为1.2.5的硬币,分别有num_1.num_2.num_5个,问不能组成的最小面值是多少?(0<=每种硬币个数<=1000,组成的面值>0) 思路: 母函数解决. ...
- 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, ...
- 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的硬币若干,问你最小的不能组成的币值为多少. 解法:写出生成函数: 然后求每项的系数即可. 因为三种硬币最多1000枚,1*1000+2*1000+5*1000=8 ...
- hdu 1085 给出数量限制的母函数问题 Holding Bin-Laden Captive!
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDOJ 1085 Holding Bin-Laden Captive! (母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
随机推荐
- Struts2拦截器总结
拦截器的本质: 拦截器就是一个类,一个实现了超级接口Interceptor的类.Interceptor接口里定义了三个方法 init(),destory(),intercept().其中inercep ...
- 关于微信浏览不能URL传参,URL中的问号被删除
关于微信浏览不能URL传参,URL中的问号被删除. 尼玛难道没有人遇到过这个问题?看了微信支付SDK3.0的代码,看到urlencode 看到了几次.实际上 在微信浏览器下 header('locat ...
- test md
[TOC] Glossary SUT SYSTEM UNDER TEST CUT CLASS UNDER TEST MUT METHOD UNDER TEST Tests without Use of ...
- Linux下C编程通过宏定义打开和关闭调试信息
GCC支持宏定义 gcc -Dmacro,将macro定义为1,我们可以利用这点在我们的代码中加入宏定义开关. #ifdef DEBUG #define pdebug(format, args...) ...
- MacOS Apache配置
仅适用于apache 2.2版本 查看版本 sudo apachectl -v 启动服务器 sudo apachectl start 打开localhost,可以看到内容为“It works! ...
- 关于BFC
参考 http://www.html-js.com/article/1866(很棒! 还有栗子) http://www.cnblogs.com/lhb25/p/inside-block-format ...
- delete了,析构函数却没有调用
析构函数在对象的生命结束时,会自动调用,大家所熟知的智能指针就是根据析构函数的这种特性而实现的,包括Qt的内存管理机制,也都是利用了析构函数的这一机制来实现的.c++创始人Bjarne Stroust ...
- 教你看懂C++类库函数定义之三---_stdcall
一切从一个C++ 类库头文件开始,现在在做一个C++的项目,期间用到一个开源的界面库DUILib(类似MFC),这个东西还不错能很容易的写出漂亮的界面,比如QQ的界面,可以去下载下来研究研究,地址:h ...
- HDU 5919 Sequence II(可持久化线段树)
[题目链接]http://acm.hdu.edu.cn/showproblem.php?pid=5919 [题目大意] 给出一个数列,每次查询数列中,区间非重元素的下标的中位数.查询操作强制在线. [ ...
- JAVA实例变量的初始化过程
假设有这样一段代码: public class Cat { private String name; private int age; public String toString() { retur ...