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

母函数,注意的是每一个式子不是无限的,所以要加上一个cot<=b和cot<=c表示一个式子只有b,c项,不要超过了
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<algorithm>
  4. #include<string.h>
  5. using namespace std;
  6. int c1[],c2[];
  7. int main()
  8. {
  9. int a,b,c;
  10. int num;
  11. while(cin>>a>>b>>c)
  12. {
  13. memset(c1,,sizeof(c1));
  14. memset(c2,,sizeof(c2));
  15. if(a==&&b==&&c==) break;
  16. for(int i=;i<=a;i++)
  17. {
  18. c1[i]=;
  19. }
  20. num = a+*b+*c;
  21. int k,cot;
  22. for(int j=;j<=num;j++)
  23. {
  24. for(k=,cot=;k+j<=num&&cot<=b;k+=,cot++)
  25. {
  26. c2[j+k]+=c1[j];
  27. }
  28. }
  29. for(int j=; j<=num; j++)
  30. {
  31. c1[j] = c2[j];
  32. c2[j] =;
  33. }
  34. for(int j=; j<=num; j++)
  35. {
  36. for(k=,cot=; k+j<=num&&cot<=c; k+=,cot++)
  37. {
  38. c2[j+k]+=c1[j];
  39. }
  40. }
  41. for(int j=; j<=num; j++)
  42. {
  43. c1[j] = c2[j];
  44. c2[j] =;
  45. }
  46. int i;
  47. for(i=;;i++)
  48. {
  49. if(!c1[i])
  50. {
  51. break;
  52. }
  53. }
  54. cout<<i<<endl;
  55. }
  56. return ;
  57. }

HDU1085 Holding Bin-Laden Captive!的更多相关文章

  1. hdu1085 Holding Bin-Laden Captive!(母函数)

    简单的母函数应用. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstrin ...

  2. hdu1085 Holding Bin-Laden Captive!【生成函数】

    列出生成函数的多项式之后暴力乘即可 #include<iostream> #include<cstdio> #include<cstring> using name ...

  3. A过的题目

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

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

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

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

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

  6. 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 ...

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

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

  8. HDOJ 1085 Holding Bin-Laden Captive! (母函数)

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

  9. HDU 1085 Holding Bin-Laden Captive! (母函数)

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

随机推荐

  1. 解决html中的乱码问题

    1.最简单粗暴的方法就是加一个meta标签,不过值得我们注意的是我们的meta标签是与我们的head标签是同一级的,所以千万不能将meta标签加到我们的head标签中. <meta http-e ...

  2. MyBatis使用动态代理报 invalid bound statement (not found) 错

    这个问题网上大部分都说xml文件中的路径不对 或者是resources之类的问题,如果那些文章的解决方案解决不了你的问题的话,可以看一下我遇到的这种情况: 前提: mybatis-config.xml ...

  3. NLP整体流程的代码

    import nltk import numpy as np import re from nltk.corpus import stopwords # 1 分词1 text = "Sent ...

  4. C++中的一类临时对象

    类名(参数名)这样的对象是临时对象,不能取地址,不能被引用,不过可以给同类型的其他对象赋值,该临时对象定以后可以进行一次操作,然后立即销毁. 当我们定义一个对象以后并不想立即给它赋初值,而是以后给它赋 ...

  5. 面试题:hibernate 第二天 快照 session oid 有用

    ## Hibernate第二天 ## ### 回顾与反馈 ### Hibernate第一天 1)一种思想 : ORM OM(数据库表与实体类之间的映射) RM 2)一个项目 : CRM 客户关系管理系 ...

  6. PrototypePattern(23种设计模式之一)

    设计模式六大原则(1):单一职责原则 设计模式六大原则(2):里氏替换原则 设计模式六大原则(3):依赖倒置原则 设计模式六大原则(4):接口隔离原则 设计模式六大原则(5):迪米特法则 设计模式六大 ...

  7. tab下拉菜单

    这个想法早就有的 (写tab下拉菜单)就觉得自己对js不是很熟   所以一直没有写 花了不少时间 <!DOCTYPE html> <html> <head> < ...

  8. netty中的PlatformDependent

    通过类名就知道这是一个平台有关的类,通过对该类的学习可以帮助我们实现一个跨平台的应用.但是有些方法放的实现不是很好,比如:isWindows0.通过File的separator就可以判断出来.没必要那 ...

  9. AR# 30522:LogiCORE RapidIO - How do system_reset and link_reset work?

    Description How do system_reset and link_rest work? Solution lnk_linkreset_n (input): In Xilinx SRIO ...

  10. nstallShield制作打包程序详解(图)

    InstallShield产品,是安装工具领域事实上的标准.InstallShield 软件是软件安装.配置软件包和升级解决方案领域内公认的标准.InstallShield已经成为安全安装软件的标准解 ...