Hdoj/hdu 1085 Holding Bin-laden captive! (Non-parent function solver)

Source: Internet
Author: User

Problem Description
We all know this bin-laden is a notorious terrorist, and he have disappeared for a long time. But recently, it's reported that he hides in hang Zhou of china!
"Oh, god! How terrible! ”

Don ' t is so afraid, guys. Although he hides in a cave of the Hang Zhou, the He dares not the go out. Laden is so bored recent years that he fling himself to some math problems, and he said that if anyone can solve his pro Blem, he'll give himself up!
ha-ha! Obviously, Laden is too proud of he intelligence! But, what's his problem?
"Given some Chinese Coins (coin) (three kinds–1, 2, 5), and their number is num_1, num_2 and Num_5 respectively, click Out Put the minimum value, 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 are 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


Main topic:
Give you the number of coins 1,2,5 yuan, to find the smallest number of ways to make up.

Analysis:
Since the mother function has not been studied, the general knowledge is used to solve it.
1, when there is no one-dollar coin, it must be 1.
2, when a dollar coin and two yuan coins can not form all the numbers between 1-4, then do not consider the five yuan of coins, this time the smallest number is a+2*b+1.
3, when the first 2 cases are satisfied, the largest number of a+2*b+5*c within all the numbers will certainly be able to take, so the minimum number is: a+2*b+5*c+1.

AC Code:

Import Java.util.Scanner; Public classmain{ Public Static void Main(string[] args) {Scanner SC =NewScanner (System.inch); while(Sc.hasnext ()) {inta =sc.nextint ();intB=sc.nextint ();intc =sc.nextint ();if(a==0&&b==0&&c==0){ Break; }if(a==0) {System. out. println (1); }Else if(A +2*b<4) {System. out. println (A +2*b+1); }Else{System. out. println (a+b*2+5*c+1); }        }    }}

Hdoj/hdu 1085 Holding Bin-laden captive! (Non-parent function solver)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.