Holding Bin-laden captive!Time
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 17379 Accepted Submission (s): 7795
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 Input
1 1 30) 0 0
Sample Output
4
Authorlcy
Recommendwe carefully selected several similar problems for you:1171 2152 2082 1709 2079
Test instructions is the requirement to find a minimum number that cannot be made up of a given coin, with a limited number of coins.
#include <stdio.h> #include <string.h> #include <algorithm>using namespace Std;int c1[8100];int c2[ 8100];int generation (int x,int y,int z) {int coin[3]={1,2,5};int num[3]={x,y,z};int max=x*1+y*2+z*5;memset (c2,0,sizeof (C2)); Memset (C1,0,sizeof (C1)); for (int i=0;i<=x;i++) {c1[i]=1;//c2[i]=0;} for (int i=1;i<3;i++) {for (int. j=0;j<=max;j++) {for (int k=0;k+j<=max&&k/coin[i]<=num[i];k+=coin[ I]) {c2[j+k]+=c1[j];}} for (int j=0;j<=max;j++) {c1[j]=c2[j];c2[j]=0;}} for (int i=0;i<=max+1;i++) {if (c1[i]==0) return i;} return C1[max];} int main () {int x,y,z;while (scanf ("%d%d%d", &x,&y,&z), x!=0| | y!=0| | z!=0) {printf ("%d\n", Generation (x, Y, z));} return 0;}
Copyright NOTICE: This article is the original blogger articles, reproduced please indicate the source.
Hdoj Holding Bin-laden captive! 1085 "female function"