Description
Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She was so surprised because she had never seen so many apples before. Each kind of apple have a size and a price to be sold. Now the little girl wants to gain more profits, but she does isn't know how. So she asks to help, and tell she the most profits she can gain.
Input
The first line there are an integer t (t <=), indicates the number of test cases.
In each case, there is four lines. In the first three lines, there is both integers S and P in each line, which indicates the size (1 <= S <=) and The price (1 <= P <= 10000) of this kind of apple.
The fourth line there are an integer V, (1 <= V <= 100,000,000) indicates the volume of the girl ' s bag.
Output
For each case, first output of the case number then follow the most profits she can gain.
Sample Input
11 12 13 16
Sample Output
Case 1:6
#include <iostream>#include<stdio.h>#include<algorithm>using namespacestd;structn{ints,p; Doublepri;} node[4];BOOLCMP (N a,n b) {if(A.PRI<B.PRI)return true; return false;}Long LongLlmax (Long LongALong Longb) { returnA>b?a:b;}intMain () {intT; CIN>>T; intC=1; while(t--) { for(intI=0;i<3; i++) {cin>>node[i].s>>NODE[I].P; Node[i].pri=1.0*node[i].s/(1.0*NODE[I].P); } intV; CIN>>W; Sort (Node,node+3, CMP); Long Longans=0; for(intI=0; i<node[0].S; i++) { for(intj=0; j<node[0].S; J + +) { Long Longtemp=i*node[1].s+j*node[2].s; if(temp>V) Break; Else { Long Longv=v-temp; Ans=llmax (ans,v/node[0].s*node[0].p+i*node[1].p+j*node[2].P); } }} cout<<" Case"<<c++<<": "<<ans<<Endl; } return 0;}
Pick Apples The third ACM provincial race