Holding Bin-laden captive!
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 17653 Accepted Submission (s): 7902
Problem descriptionwe 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 (coins) (three kinds--1, 2, 5), and their number is num_1, num_2 and num_5 respectively, please OU Tput the minimum value that's cannot pay with given coins. "
You, super Acmer, should solve the problem easily, and don ' t forget to take $25000000 from bush!
Inputinput 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.
Outputoutput the minimum positive value that one cannot pay with given coins, one line for one case.
Sample INPUT1 1 30 0 0
Sample Output4
Authorlcy
Recommendwe has carefully selected several similar problems for you:1398 2152 2082 1709 20,791 began to want to use DP, but dp[1000][1000][ 1000] Not so large (three-dimensional array of the largest is [790][790][790]codeblocks Pro-Test), so directly to find the law. To be careful, WA two times, the first time is less 3,0,1 this situation, my answer is 9, the correct answer is 4. The second time is because there is no writing &&n1+n2+n5>0 (Orz ...)
#include <queue>#include<math.h>#include<stdio.h>#include<string.h>#include<string>#include<iostream>#include<algorithm>using namespacestd;#defineN 1002intN1,n2,n5;intZiji (intN1,intN2,intN5) { intans; if(n1==0) ans=1; Else if(n2==0&&n1<2) ans=2; Else if(n1==1&&n2==1) ans=4; Else if(n1==2&&n2==0&&n5>0) ans=3; Else if(n1==3&&n2==0&&n5>0) ans=4;//for the first time, this situation is missing. Else{ans=n1+n2*2+n5*5+1; } returnans;}intMain () { while(~SCANF ("%d%d%d", &n1,&n2,&n5) &&n1+n2+n5>0) {cout<<ziji (N1,N2,N5) <<Endl; } return 0;}
Parent Function Method:
HDU 1085 Holding Bin-laden captive! (female function, or pattern)