zoukankan      html  css  js  c++  java
  • 杭电 1085 Holding BinLaden Captive!


    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
     
     

    G(X)=(1+X+X^2+X^3+……)(1+X^2+X^4+……)(1+X^5+X^10+……)不能组合成那个最小数

     1 #include<stdio.h>
     2 #include<string.h>
     3 int a[8002];
     4 int b[8002];
     5 
     6 int main()
     7 {
     8     int i,j,k,x,y,z,ok;
     9     while(scanf("%d%d%d",&x,&y,&z),x||y||z)
    10     {
    11         ok=1;
    12         memset(a,0,sizeof(a));
    13         memset(b,0,sizeof(b));
    14         for(i=0;i<=x;i++)//初始化1
    15         {
    16             a[i]=1;
    17             b[i]=0;
    18         }
    19         for(j=0;j<=x;j++)//计算2
    20             for(k=0;k<=y;k++)
    21                 b[j+2*k]+=a[j];
    22         for(i=0;i<=x+y*2;i++)
    23         {
    24             a[i]=b[i];
    25             b[i]=0;
    26         }
    27 
    28         for(j=0;j<=x+y*2;j++)//计算5
    29             for(k=0;k<=z;k++)
    30                 b[j+5*k]+=a[j];
    31         for(i=0;i<=x+y*2+5*z;i++)
    32         {
    33             a[i]=b[i];
    34             b[i]=0;
    35         }
    36 
    37         for(i=1;i<=8000;i++)//查找
    38             if(a[i]==0)
    39             {
    40                 ok=0;
    41                 printf("%d\n",i);
    42                 break;
    43             }
    44         if(ok) printf("%d\n",i);
    45     }
    46     return 0;
    47 
    48 }

      

    杭电1171、1709 20692152
  • 相关阅读:
    C++11 并发指南四(<future> 详解三 std::future & std::shared_future)(转)
    转: 关于 ssl的建立链接的过程
    工信部电信投诉网站入口
    rfc 标准文档目录
    转: 七牛云的开源播放器的使用指南
    转: Android基于HLS和RTMP协议的第三方SDK选择
    转:Android中Context详解 ---- 你所不知道的Context
    android开发推荐书籍列表
    转:java 类名 this 的使用
    转: android studio 消除SDK更新时的“https://dl-ssl.google.com refused”错误
  • 原文地址:https://www.cnblogs.com/xiaofanke/p/3102480.html
Copyright © 2011-2022 走看看