Holding Bin-laden captive!
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 19908 Accepted Submission (s): 8865
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 Three kinds of coins, enter the number of three coins, ask all these coins can not pay the minimum amount of money. Use the parent function to solve, although do a little longer, the idea of basic mastery.
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespacestd;intB1:10000];intc2[10000];intc3[4000];intMain () {intA,b,c; while(SCANF ("%d%d%d", &a,&b,&c)!=eof&& (a| | b| |c) {memset (C1),0,sizeof(C1)); memset (C2,0,sizeof(C2)); Memset (C3,0,sizeof(C3)); for(intI=0; i<=a; i++) C1[i]=1; for(intI=0; i<=a; i++) for(intj=0; j<=2*b; j+=2) C2[i+j]+=C1[i]; for(intI=0; i<=a+b*2; i++) {C1[i]=C2[i]; C2[i]=0; } for(intI=0; I<= (A *1) + (b*2); i++) for(intj=0; j<=5*c; j+=5) C2[i+j]+=C1[i]; for(intI=0; i<=a+b*2+c*5; i++) C1[i]=C2[i]; /*for (int i=0;i<=a+2*b+5*c;i++) cout<<c1[i]<<endl; cout<<endl;*/ for(intI=1; i<=a+2*b+5*c+1; i++) if(c1[i]==0) {printf ("%d\n", i); Break; } } return 0;}
View Code
hdu_1085_holding Bin-laden captive!_ Female function