zoukankan      html  css  js  c++  java
  • HD1085 Holding Bin-Laden 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

    大神说,这道题用母函数,但惭愧的说,自己还不了解母函数这东东,只能用数学的知识去做。这道题也告诉我们用1 ,2,5制作硬币,能够用尽可能少的硬币种数去表示其它的数

    #include<iostream>
    using namespace std;
    int main(){
        int a,b,c;
        while(cin>>a>>b>>c)
        {
            if(a==0 && b==0 && c==0)
                break;
            else{
                if(a==0)
                    cout<<1<<endl;
                else{
                    if(a+2*b<4)
                        cout<<a+2*b+1<<endl;
                    else
                        cout<<a+2*b+1+5*c<<endl;
                    }
                }
        }
        return 0;
    }
    //一定要注意{},不要偷懒
  • 相关阅读:
    [转载]pda 和pc 之间的文件操作(利用Microsoft ActiveSync同步文件数据)
    获取XML文件中内容大小
    听猪的“旅行的意义”有感
    If a file is locked, you can wait until the lock times out to redeploy, or s
    七个顶级的心理寓言(转载)
    html table 上下左右边框
    判断浏览器动态加载CSS等内容
    课程表
    input文本框、文字、按钮、图片 垂直居中对齐
    JUnit3
  • 原文地址:https://www.cnblogs.com/LZYY/p/3291769.html
Copyright © 2011-2022 走看看