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;
    }
    //一定要注意{},不要偷懒
  • 相关阅读:
    非root用户在linux下安装多个版本的CUDA和cuDNN(cuda 8、cuda 10.1 等)
    python相关总结
    可视化滤波器
    Ubuntu 和windows程序区别
    远程服务器运行代码相关
    Ubuntu
    jmeter学习(1)基础支持+安装部署
    python中eval方法的使用
    mysql学习(4)python操作数据库
    mysql学习(3)10045错误,连接不上数据库
  • 原文地址:https://www.cnblogs.com/LZYY/p/3291769.html
Copyright © 2011-2022 走看看