Holding Bin-Laden Captive!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 17732    Accepted Submission(s): 7940

Problem Description
We 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!

 
Input
Input 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.
 
Output
Output the minimum positive value that one cannot pay with given coins, one line for one case.
 
Sample Input
1 1 3 0 0 0
 
Sample Output
4
题解:money数组存的是面值,t数组存的是当前面值的个数
母函数为:
(1+x+x^2+x^3+.....+x^a)*(1+x^2+x^4+....+x^2b)*(1+x^5+x^10+...+x^5c);
代码:
 #include<stdio.h>
#include<string.h>
const int MAXN=;
int a[MAXN],b[MAXN];
int main(){
int x,y,z,sum;
int money[],t[];
while(scanf("%d%d%d",&x,&y,&z),x||y||z){
memset(a,,sizeof(a));memset(b,,sizeof(b));//初始化。。。
for(int i=;i<=x;i++)a[i]=,b[i]=;
t[]=x;t[]=y;t[]=z;
money[]=;money[]=;money[]=;
sum=money[]*t[];
for(int i=;i<;i++){
for(int j=;j<=sum;j++)
for(int k=;k<=money[i]*t[i];k+=money[i])
b[j+k]+=a[j];
sum+=money[i]*t[i];
for(int j=;j<=sum;j++)
a[j]=b[j];
}
//printf("%d\n",sum);
for(int i=;i<=sum+;i++)
if(!a[i]){
printf("%d\n",i);
break;
}
}
return ;
}
extern "C++"{
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int INF = 0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef unsigned long long ULL; void SI(int &x){scanf("%d",&x);}
void SI(double &x){scanf("%lf",&x);}
void SI(LL &x){scanf("%lld",&x);}
void SI(char *x){scanf("%s",x);} }
const int MAXN = ;
int a[MAXN],b[MAXN];
int num[];
int v[];
int main(){
while(~scanf("%d%d%d",&num[],&num[],&num[]),num[]|num[]|num[]){
mem(a,);mem(b,);
v[] = ;v[] = ;v[] = ;
int sum = ;
for(int i = ;i <= num[];i++)a[i] = v[],b[i] = ,sum += v[i] * num[i];
//int sum = num[0] * v[0];
for(int i = ;i <= ;i++){
for(int j = ;j <= sum;j++){
for(int k = ;k <= num[i];k++){
b[j + k * v[i] ] += a[j];
}
}
// sum += num[i] * v[i];
for(int j = ; j <= sum; j++)a[j] = b[j],b[j] = ;
}
int ans;
for(int i = ;i <= sum + ;i++){
if(a[i] == ){
ans = i;
break;
}
}
printf("%d\n",ans);
}
return ;
}

Holding Bin-Laden Captive!(母函数)的更多相关文章

  1. HDU 1085 Holding Bin-Laden Captive!(母函数,或者找规律)

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

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

  3. 【hdoj_1085】Holding Bin-Laden Captive![母函数]

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1085 可以这样理解题意:给出1元,2元和5元的三种硬币若干,每种硬币数量给出,现在可以从所有的硬币中,选出 ...

  4. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  5. A过的题目

    1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...

  6. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  7. 缓冲区溢出利用——捕获eip的傻瓜式指南

    [译文] 摘要:为一个简单的有漏洞程序写一个简单的缓冲区溢出EXP,聚焦于遇到的问题和关键性的教训,提供详细而彻底的描述 内容表:1. I pity the fool, who can't smash ...

  8. 用主题模型可视化分析911新闻(Python版)

    本文由 伯乐在线 - 东狗 翻译,toolate 校稿.未经许可,禁止转载!英文出处:blog.dominodatalab.com.欢迎加入翻译小组. 本文介绍一个将911袭击及后续影响相关新闻文章的 ...

  9. How do I learn mathematics for machine learning?

    https://www.quora.com/How-do-I-learn-mathematics-for-machine-learning   How do I learn mathematics f ...

  10. Labeled Faces in the Wild 人脸识别数据集 部分测试数据

    development test set Note: images displayed are original (non-aligned/funneled) images. match pairs ...

随机推荐

  1. UIButton基础知识

    基本属性 1.frame;坐标:title:titlecolor:字体颜色:titleShadowColor:字体阴影:image:图片: backgroundImage:背景图片: 2.forsta ...

  2. 算法分析-动态规划(cut_rod)

    什么是动态规划,我们要如何描述它? 动态规划算法通常基于一个递推公式及一个或多个初始状态. 当前子问题的解将由上一次子问题的解推出.使用动态规划来解题只需要多项式时间复杂度, 因此它比回溯法.暴力法等 ...

  3. Java日期时间使用(转)

    Java日期时间使用总结 转自:http://lavasoft.blog.51cto.com/62575/52975/   一.Java中的日期概述   日期在Java中是一块非常复杂的内容,对于一个 ...

  4. 解决Delphi自带UTF8解码缺陷(使用API)

    因为Delphi自带的转换函数遇到其无法识别的字符串就返回空,下面函数可解决该问题. function DecodeUtf8Str(const S: UTF8String): WideString;v ...

  5. 使用 rpython 在 windows 下生成的程序无法运行

    在 windows 用rpython编译出的文件总是无法运行,报 通过跟踪发现,rpython 每次都会将生成的C代码.Makefile 等放置在 %TEMP%\usession-release-2. ...

  6. OpenLayers访问WTMS服务及添加Googlemap

    1.访问WMS服务 首先需要发布WMS服务,才能进行地图WMS服务访问.这里不说怎么发布WMS服务,直接看怎么调用,代码如下: 代码 Code highlighting produced by Act ...

  7. Python学习笔记5-字符串、bool、数值操作和数组字典排序

    1.字符串 # 字符串数字之间转换 # x = int("6") # print type(x) #<type 'str'> # y = str(6) # print ...

  8. 20151225--easyUI

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  9. Java SE基础部分——常用类库之NumberFormat(数字格式化)

    数字格式化常用方法:DecimalFormat和NuberFormat. //2016060524 数字格式化学习 //数字格式化 两种方法 一种直接使用NumberFormat,另一种Decimal ...

  10. 教你wamp下多域名如何配置

    wamp下多域名配置问题 1.找到wamp安装目录的apache安装目录 找到 httpd.conf文件 例如我安装的目录为 E:\wamp\bin\apache\apache2.2.8\conf\h ...