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

    Holding Bin-Laden Captive!

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


    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
     
        这个题的是用母函数写的,可能复杂了些~~~一会儿研究下,更简单的解法!
    #include <stdio.h>
    #include <stdlib.h>
    
    int  temp1[10000], temp2[10000];
    
    int main(int argc, char *argv[])
    {
        int num_1, num_2, num_5, i, j;
        int a[1005], b[2005], c[5005];
        while( (scanf( "%d%d%d", &num_1, &num_2, &num_5 )!= EOF)&&( num_1||num_2||num_5 ) )
        {
               memset(a, 0, 1005 * sizeof(int));
               memset(b, 0, 2005 * sizeof(int));
               memset(c, 0, 5005 * sizeof(int));
               memset(temp1, 0,  10000 * sizeof(int));
               memset(temp2, 0,  10000 * sizeof(int));
               //printf( "0 0 0\n" );     
               for( i = 0; i <= num_1; i++ )
                    a[i] = 1;
               for( i = 0; i <= num_2 * 2; i += 2 )
                    b[i] = 1;
               for( i = 0; i <= num_5 * 5; i += 5 )
                    c[i] = 1;
                    
               /*for( i = 0; i <= num_1; i++ )
                    printf( "%d ", a[i] );
               printf( "\n" );*/
               
               
               
               for( i = 0; i <= num_1; i++ )
                    for( j = 0; j <= num_2 * 2 ; j += 2 )
                         temp1[i+j] += a[i] * b[j];
               
               for( i = 0; i <= 3000; i++ )
                    for( j = 0; j <= num_5 * 5; j += 5 )
                         temp2[i+j] += temp1[i] * c[j];
               for( i = 0; i < 10000; i++ )
                    if( temp2[i] == 0 )
                        break;
               printf( "%d\n", i );    
        }
      
     // system("PAUSE");    
      return 0;
    }
  • 相关阅读:
    CSS文本超出指定行数省略显示
    Vue框架H5商城类项目商品详情点击返回弹出推荐商品弹窗的实现方案
    vue项目强制清除页面缓存
    使用es6的then()方法封装jquery的ajax请求
    微信小程序——微信卡券的领取和查看
    vue项目如何通过前端实现自动识别并配置服务器环境地址
    HTML中的Meta标签详解
    复用微信小程序源码包后仍然有原小程序的版本管理怎么处理
    译: 3. Axis2快速入门指南
    译: 2. Apache Axis2安装指南
  • 原文地址:https://www.cnblogs.com/yizhanhaha/p/3075237.html
Copyright © 2011-2022 走看看