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 ...
随机推荐
- python 缩进导致的问题
今天写Python 看着没有问题 运行就各种问题 object has no attribute 最后发现 Vim 设置里面有个 tabstop 我设置的是4 应该设置成8
- Android Log工具类
import java.text.SimpleDateFormat; import java.util.Date; import android.util.Log; public class LogU ...
- CSS3 Media Query
在移动端火爆的今日,一个好的web应用不仅仅要有对应移动平台的APP,自己web网页也需要对不同屏幕大小的移动设备进行支持,也就是我们所说的响应式web页面. 本篇文章就来介绍下最常见的响应式页面的实 ...
- [LeetCode]题解(python):138-Copy List with Random Pointer
这道题目不是太懂,参考了http://www.cnblogs.com/zuoyuan/p/3745126.html的博客. 题意: A linked list is given such that e ...
- get the execution time of a sql statement.
declare @d datetimeset @d = GETDATE()select * from dbo.spt_valuesselect [语句执行花费时间(毫秒)]= DATEDIFF(ms, ...
- 一維條碼 EAN13 的編碼方式
何謂 EAN-13碼 ? ▲ 國家代號(3位數) 中華民國的國家代號為471. ▲ 廠商代號(6位數) 由本會核發給廠商6位數的廠商代號. ▲ 商品代號(3位數) 由廠商自行編定,按一物一號的原則,不 ...
- delphi 7 下安装 indy 10.5.8 教程
本教程用 indy 10.5.8 替换 delphi 7 自带的 indy 版本,让大家深入了解 delphi 组件安装的方法. 第一步:下载 indy 10.5.8 组件,解压到合适的目录里.如 D ...
- file_get_contents post数据
//默认模拟的header头 private function _defaultHeader() { $header = "User-Agent:Mozilla/5.0 (Windows; ...
- UVA - 297Quadtrees(四分图)
Quadtrees Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Submit Statu ...
- Android animation学习笔记之view/drawable animation
前一章中总结了android animation中property animation的知识和用法,这一章总结View animation和Drawable animation的有关知识: View ...