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. MySQL----数据的显示位宽

    问题:在MySQL表中的列可以定义它显示的位宽.那么定义了位宽会不会影响数据的取值范围呢? 测试: 1.定义一个用于测试的表 create table t(x int,y int(2),z int(2 ...

  2. Gentoo Linux 学习笔记1

         Gentoo Linux是一个基于portage进行包管理的Linux发行版,最早版本始于2002年.其官方官网为http://www.gentoo.org 目前,Gentoo Linux已 ...

  3. 使用keil判断ARM的冷启动和热启动的方法

    微处理器:LPC2114 编译环境:Keil MDK V4.10 思路: 常把单片机系统的复位分为冷启动和热启动.所谓冷启动,也就是一般所说的上电复位,冷启动后片内外RAM的内容是随机的,通常是0x0 ...

  4. java--工具方法

    根据时间戳得到具体的时间: public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat(& ...

  5. css案例学习之父子块的margin

    两边还会有些距离,这是body默认的. 代码: <head> <title>父子块的margin</title> <style type="text ...

  6. 【Daily】 2014-4-28

    KEEP GOING  表达产品想法, 探讨产品问题, 倾听可能性问题. 一次就做好, 有成果展示, 主动展示 先确立图, 后确立代码. Hold dream, and never let it go ...

  7. Struts2 请求参数接收

    在Struts2中提供了更为简单的参数请求与接收方法,可以直接在Action中定义属性:Struts2通过反射机制将参数反射到属性的set方法上实现参数的传递: GET方式传送参数 <strut ...

  8. MySQL- 锁机制及MyISAM表锁

    锁是计算机协调多个进程或线程并发访问某一资源的机制.在数据库中,除传统的计算资源(如CPU.RAM.I/O等)的争用以外,数据也是一种供许 多用户 共享的资源.如何保证数据并发访问的一致性.有效性是所 ...

  9. c++犯的错误

    (1) 定义的变量一定要初始化:long long llnum;  int nNum = 4; llnum = nNum; (llnum的值不是4,高四位是随机数)    int型变量赋值给longl ...

  10. gdb调试python

    一.概述 有时我们会想调试一个正在运行的Python进程,或者一个Python进程的coredump.例如现在遇到一个mod_wsgi的进程僵死了,不接受请求,想看看究竟是运行到哪行Python代码呢 ...