有num1个 1 ,num2个 2 ,num3个 5
问它们不能组成的最小正整数是谁

样例的母函数 (1+X)(1+X2)(1+X5+X10+X15)
展开后 X4的系数为0

Sample Input
1 1 3
0 0 0

Sample Output
4

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <string>
# include <cmath>
# include <queue>
# include <list>
# define LL long long
using namespace std ; int c1[], c2[] ;
int w[] = { , , , };
int num[]; int main()
{
//freopen("in.txt","r",stdin) ;
int n ;
while(scanf("%d %d %d", &num[], &num[], &num[])!= EOF )
{
if (num[] == && num[] == && num[] == )
break ;
int Max = num[]*w[]+num[]*w[]+num[]*w[]; memset(c1, , sizeof(c1));
memset(c2, , sizeof(c2));
int i , j , k ;
for(i=; i<=w[]*num[]; i+=w[])
c1[i] = ;
int len = w[]*num[];
for(i=; i<=; ++i)
{
for(j=; j<=len; ++j)
for(k=; k<=w[i]*num[i]; k+=w[i])
{
c2[k+j] += c1[j];
}
len += w[i]*num[i];
for(j=; j<=len; ++j)
{
c1[j] = c2[j];
c2[j] = ;
}
}
for(i=; i<=Max; ++i)
if(c1[i] == )
{
printf("%d\n", i);
break;
}
if(i == Max+)
printf("%d\n", i);
}
return ;
}

hdu 1085 有num1个 1 ,num2个 2 ,num3个 5 (母函数)的更多相关文章

  1. hdu 1171 有num1个w1 , num2个w2 ……. (母函数)

    输入n,代表学院里面有n种设备,并且在下面输入n行,每一行输入v,m代表设备的价格为v,设备的数量是m.然后要求把这些设备的总价值分摊,尽量平分,使其总价值接近相等,最好是相等 比如样例二(1+X10 ...

  2. 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, ...

  3. 居然因为交换错了好几把。。。。,还有坑点是num1可以大于num2

    完数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  4. hdu 1028 && hdu 1398 && hdu 1085 && hdu 1171 ——生成函数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1028 就是可以用任意个1.2.3....,所以式子写出来就是这样:(1+x+x^2+...)(1+x^2+ ...

  5. 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), //展 ...

  6. HDU 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)

    题意: 有面值分别为1.2.5的硬币,分别有num_1.num_2.num_5个,问不能组成的最小面值是多少?(0<=每种硬币个数<=1000,组成的面值>0) 思路: 母函数解决. ...

  7. HDU 1085 Holding Bin-Laden Captive --生成函数第一题

    生成函数题. 题意:有币值1,2,5的硬币若干,问你最小的不能组成的币值为多少. 解法:写出生成函数: 然后求每项的系数即可. 因为三种硬币最多1000枚,1*1000+2*1000+5*1000=8 ...

  8. hdu 1085

    额    母函数 #include <cstdio> #include <cstring> int a[3],b[3]= {1,2,5}; int c1[10001],c2[1 ...

  9. HDOJ/HDU 1085 Holding Bin-Laden Captive!(非母函数求解)

    Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for ...

随机推荐

  1. IL指令集

    声明: 1.本指令集搜集自网上各个论坛帖子,欢迎补充 IL指令集 名称 说明     Add 将两个值相加并将结果推送到计算堆栈上.     Add.Ovf 将两个整数相加,执行溢出检查,并且将结果推 ...

  2. Tomcat性能调优及JVM内存工作原理

    Java性能优化方向:代码运算性能.内存回收.应用配置. 注:影响Java程序主要原因是垃圾回收,下面会重点介绍这方面 代码层优化:避免过多循环嵌套.调用和复杂逻辑.Tomcat调优主要内容如下:1. ...

  3. ZeroMQ API(二) 上下文

    1.创建上下文 1.1 zmq_ctx_new(3) 1.1.1 名称 zmq_ctx_new - 创建新的ZMQ上下文 1.1.2 概要 void * zmq_ctx_new(); 1.1.3 描述 ...

  4. input新类型详解

    http://www.webhek.com/post/html5-input-type.html

  5. c++中引用的用法(转)

    from here 对于习惯使用C进行开发的朋友们,在看到c++中出现的&符号,可能会犯迷糊,因为在C语言中这个符号表示了取地址符,但是在C++中它却有着不同的用途,掌握C++的&符号 ...

  6. oracle常见错误对应代码与含义

    本篇文章是对oracle错误代码进行了详细的总结与分析,需要的朋友参考下 ORA-00001: 违反唯一约束条件 (.) ORA-00017: 请求会话以设置跟踪事件 ORA-00018: 超出最大会 ...

  7. Linux基础-Shell脚本

    任务一目标:自动部署.初始配置.并启动nginx反向代理服务 把任务拆分来看-自动部署部分,就是先下载安装Nginx 首先建立一个很NB霸气的目录还有一个同样NB霸气的.sh文件 /NBshell/M ...

  8. jQuery入门——(二)

    0.基本知识 $与jQuery等价,$.fun代表jQuery的全局方法. jQuery必须首先导入JQuery库, jQuery的事件都不带on,例如 $("#btn").cli ...

  9. vue写出放大镜的效果

    用vue写出放大镜查看图片的效果. 安装 npm install vue2.0-zoom 引入 import imgZoom from 'vue2.0-zoom' 组件 components: { i ...

  10. pytorch--cnn的理解

    class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.conv1 = nn.Conv2d(1, ...