zoukankan      html  css  js  c++  java
  • 山东省第三届acm

    #include <iostream>
    #include <stdio.h>
    using namespace std;
    int s[4],p[4];

    long long llmax(long long a,long long b)
    {
        return a>b?a:b;
    }
    int main()
    {
        int t;
        cin>>t;
        int c=1;
        while(t--)
        {
            for(int i=1; i<=3; i++)
                cin>>s[i]>>p[i];
            int V;
            cin>>V;
            int k1=1,k2,k3;
            for(int i=2; i<=3; i++)
            {
                if(p[i]*s[k1]>p[k1]*s[i])//判断优先级
                    k1=i;
            }
            if(k1==1){k2=2;k3=3;};//k1是最优的物品,k2,k3是谁没有关系
            if(k1==2){k2=1,k3=3;};
            if(k1==3){k2=1,k3=2;};
            long long ans=0;
            for(int i=0; i<s[k1]; i++)//枚举
            {
                for(int j=0; j<s[k1]; j++)
                {
                    long long temp=i*s[k2]+j*s[k3];//temp为 i+j件 次品的容量
                    if(temp>V)
                        break;
                    else
                    {
                        long long v=V-temp;//     v为i+j件次品放下后剩余的空间
                        ans=llmax(ans,v/s[k1]*p[k1]+i*p[k2]+j*p[k3]);//选最大值
                    }
                }
            }
            cout<<"Case "<<c++<<": "<<ans<<endl;
        }
        return 0;
    }

  • 相关阅读:
    宏定义中的常见使用
    VS 对于LINK fatal Error 问题 解决方案
    cocos2d-x中常见的场景切换
    给新建的Cocos2d-x 3.X的Win32工程添加CocoStudio库
    2048之军衔篇 反馈 有事留言
    http 错误代码表
    华为S5700交换机初始化和配置SSH和TELNET远程登录方法
    Linux修改网卡名
    Linux如何配置bond
    linux系统下如何挂载NTFS移动硬盘
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/3700081.html
Copyright © 2011-2022 走看看