sdut 2408 Pick apples

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 is so surprised because she has never seen so many apples before. Each kind of apple has a size and a price to be sold. Now the little girl wants to gain more profits, but she does not know how. So she asks you for help, and tell she the most profits she can gain.

 

Input

In the first line there is an integer T (T <= 50), indicates the number of test cases.
In each case, there are four lines. In the first three lines, there are two integers S and P in each line, which indicates the size (1 <= S <= 100) and the price (1 <= P <= 10000) of this kind of apple.

In the fourth line there is an integer V,(1 <= V <= 100,000,000)indicates the volume of the girl's bag.

Output

For each case, first output the case number then follow the most profits she can gain.

Sample Input

1
1 1
2 1
3 1
6

Sample Output

Case 1: 6

题意:就是个多重背包,不过物品的种类是固定三种,wi vi,体积给定,使价值最大
分析:背包很大,物品单个体积很小,可以先考虑贪心,贪心取性价比比较高的,物品要完整取,那么有可能会放弃一些
性价比高的,加上剩余的体积,取剩余的两种,使得总价值更高,那么假设性价比从大倒小排序后 ,那么si表示i取几个
s1*w1=s2*w2,这个时候两种物品的体积相同,那么也就是说第二种物品最多取s2-1个,可以相出出s2最大不会大于100
那么我们枚举性价比不是最高的两种物品个数,剩下的全部区性价比最高的,O(100*100)就能解决问题
posted @ 2017-04-27 16:13  N维解析几何  阅读(199)  评论(0编辑  收藏  举报