zoukankan      html  css  js  c++  java
  • HDOJ 1085 Holding Bin-Laden Captive! (母函数)

    Holding Bin-Laden Captive!

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


    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
     
    Author
    lcy
     
     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 
     5 using namespace std;
     6 
     7 const int maxn=1010000;
     8 const int valu[4]={0,1,2,5};
     9 int c1[maxn],c2[maxn];
    10 int a,b,c;
    11 
    12 void isOK()
    13 {
    14     int t[4];
    15     t[0]=0;t[1]=a;t[2]=b;t[3]=c;
    16     memset(c1,0,sizeof(c1));
    17     memset(c2,0,sizeof(c2));
    18     int n=1*t[1]+2*t[2]+5*t[3];//最大的项数
    19     for(int i=0;i<=a;i++)
    20     {
    21         c1[i]=1;
    22     }
    23     for(int i=2;i<=3;i++)//层数的限制
    24     {
    25         for(int j=0;j<=n;j++)
    26         {
    27             for(int k=0;k+j<=n&&k<=valu[i]*t[i];k+=valu[i])//个数的限制
    28             {
    29                 c2[k+j]+=c1[j];
    30             }
    31         }
    32         for(int j=0;j<=n;j++)
    33         {
    34             c1[j]=c2[j];  c2[j]=0;
    35         }
    36     }
    37 
    38     for(int i=0;i<=n+1;i++)
    39     {
    40         if(c1[i]==0)
    41         {
    42             printf("%d
    ",i);
    43             break;
    44         }
    45     }
    46 }
    47 
    48 int main()
    49 {
    50 while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    51 {
    52     if(a==0&&b==c&&c==0) break;
    53     isOK();
    54 }
    55     return 0;
    56 }
  • 相关阅读:
    Sql Server 存储过程删除一个表里(除ID外)完全重复的数据记录
    把一个库中的表复制到另外一个库的表中(Sql server 2005)
    ajax执行后台返回的提交表单及JS
    WinCE中使用本地数据库SQLite以及得到当前应用程序所在路径
    如何评测一个软件工程师的计算机网络知识水平与网络编程技能水平
    如何评测软件工程知识技能水平?
    深入理解TCP协议及其源代码
    Socket与系统调用深度分析
    创新产品的需求分析:未来的图书会是什么样子?
    ubuntu小问题集合
  • 原文地址:https://www.cnblogs.com/CKboss/p/3165208.html
Copyright © 2011-2022 走看看