zoukankan      html  css  js  c++  java
  • 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)就能解决问题
  • 相关阅读:
    oracle 复制表结构 复制表数据 sql 语句
    Linux rsync实现断点续传
    qt实现一个简单的计算器
    python脚本0b文件处理
    同步和互斥
    python中的randint,引入模块
    python中常见的三种句型if,while,for
    python中的变量,运算符
    python安装与使用
    常见dos命令总结
  • 原文地址:https://www.cnblogs.com/jihe/p/6774797.html
Copyright © 2011-2022 走看看