【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

1.N/s1 3.s1和s2的值较小

假设买了s2个1和s1个2

那么这两种物品占的体积就一样大了。

即都为s1s2

而第一种物品价值为s2
v1第二种物品价值为s1v2

那么

如果s2
v1>s1v2的话。

可以想见,如果第二种物品的数量超过了s1的话,显然可以把它占的体积都用来买物品1,因为那样更优。

则我们第二种物品最多只要枚举到s1就可以了。

同理s2
v1<=s1*v2的话.

第一种物品只要枚举到s2就可以了。

【代码】

/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
8.whatch out the detail input require
*/
#include <bits/stdc++.h>
#define ll long long
using namespace std; ll n,s1,v1,s2,v2; int main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
int T,kase = 0;
cin >> T;
while (T--){
cin >> n >> s1 >> v1 >> s2 >> v2;
ll ans = 0;
if (n/s1<1e6){
for (int i = 0;i <= n/s1;i++){
ll temp = 1ll*i*v1;
ll tn = n - 1LL*s1*i;
temp += v2*(tn/s2);
ans = max(ans,temp);
}
}else if (n/s2<1e6){
for (int i = 0;i <= n/s2;i++){
ll temp = 1ll*i*v2;
ll tn = n - 1LL*s2*i;
temp += v1*(tn/s1);
ans = max(ans,temp);
} }else {
if (s2*v1<s1*v2){
for (int i = 0;i <= s2;i++){
ll temp = 1ll*i*v1;
ll tn = n - 1LL*s1*i;
temp += v2*(tn/s2);
ans = max(ans,temp);
}
}else{
for (int i = 0;i <= s1;i++){
ll temp = 1ll*i*v2;
ll tn = n - 1LL*s2*i;
temp += v1*(tn/s1);
ans = max(ans,temp);
}
}
}
cout <<"Case #"<<++kase<<": "<<ans<<endl;
}
return 0;
}

【例题 7-11 UVA - 12325】Zombie's Treasure Chest的更多相关文章

  1. UVa 12325 - Zombie's Treasure Chest-[分类枚举]

    12325 Zombie’s Treasure Chest Some brave warriors come to a lost village. They are very lucky and fi ...

  2. UVa 12325 Zombie's Treasure Chest【暴力】

    题意:和上次的cf的ZeptoLab的C一样,是紫书的例题7-11 不过在uva上交的时候,用%I64d交的话是wa,直接cout就好了 #include<iostream> #inclu ...

  3. uva 12325 Zombie's Treasure Chest

    https://vjudge.net/problem/UVA-12325 题意: 一个箱子,体积为N 两种宝物,体积为S1.S2,价值为V1.V2,数量无限 最多装多少价值的宝物 数据范围:2^32 ...

  4. Uva 12325 Zombie's Treasure Chest (贪心,分类讨论)

    题意: 你有一个体积为N的箱子和两种数量无限的宝物.宝物1的体积为S1,价值为V1:宝物2的体积为S2,价值为V2.输入均为32位带符号的整数.你的任务是最多能装多少价值的宝物? 分析: 分类枚举, ...

  5. UVA - 12325 Zombie's Treasure Chest (分类搜索)

    题目: 有一个体积为N的箱子和两种数量无限的宝物.宝物1的体积为S1,价值为V1:宝物2的体积为S2,价值为V2.输入均为32位带符号整数.计算最多能装多大价值的宝物,每种宝物都必须拿非负整数个. 思 ...

  6. G - Zombie’s Treasure Chest(动态规划专项)

    G - Zombie’s Treasure Chest Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d &am ...

  7. 一道看似dp实则暴力的题 Zombie's Treasure Chest

     Zombie's Treasure Chest 本题题意:有一个给定容量的大箱子,此箱子只能装蓝宝石和绿宝石,假设蓝绿宝石的数量无限,给定蓝绿宝石的大小和价值,要求是获得最大的价值 题解:本题看似是 ...

  8. HDU 4091 Zombie’s Treasure Chest 分析 难度:1

    Zombie’s Treasure Chest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  9. UVA 12325 Zombie'sTreasureChest 宝箱 (分类枚举)

    看上去非常像背包的问题,但是体积太大了. 线性规划的知识,枚举附近点就行了,优先选性价比高的, 宝物有两种体积为S0,价值V0,体积S1,价值V1. 枚举分以下几种: 1:枚举拿宝物1的数量,然后尽量 ...

随机推荐

  1. 在Linux的终端中显示BMPString的内容

    在上一篇博文中,介绍了怎样在 Windows 的控制台界面下输出 BMPString 的内容,可是那里的方法在 Linux 下不适用.假设将那里的演示样例代码放到 Linux 下运行.输出的结果为乱码 ...

  2. Android学习笔记(9):使用XML文件和Java代码控制UI界面

    Android推荐使用XML文件设置UI界面.然后用Java代码控制逻辑部分,这体现了MVC思想. MVC全名是Model View Controller.是模型(model)-视图(view)-控制 ...

  3. hdu_4430,二分

    注意处理溢出 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm ...

  4. [学习笔记]HTTP协议

    转自:www.cnblogs.com/li0803/archive/2008/11/03/1324746.html Author :Jeffrey 引言 HTTP是一个属于应用层的面向对象的协议,由于 ...

  5. 使用python fabric搭建RHEL 7.2大数据基础环境以及部分优化

    1.使用python fabric进行Linux基础配置 使用python,可以让任何事情高效起来,包括运维工作,fabric正式这样一套基于python2的类库,它执行本地或远程shell命令提供了 ...

  6. ReactiveCocoa结合了几种编程风格

    函数式编程(Functional Programming):使用高阶函数,例如函数用其他函数作为参数.响应式编程(Reactive Programming):关注于数据流和变化传播.所以,你可能听说过 ...

  7. 服务器http处理流程

    网络请求.处理的组织: context Facade模式/指令处理引擎/简单处理机: 响应码: 只要有响应码就代表服务器已经接收到请求:无响应代表网络层出现问题,与服务器无关. 处理步骤: 1)模块( ...

  8. UI Framework-1: Aura Focus and Activation

    Focus and Activation Focus and Activation are closely related.   Definitions Focused window - this i ...

  9. DNS Prefetching

    For Developers‎ > ‎Design Documents‎ > ‎ DNS Prefetching 目录 1 Problem 2 Solution 3 Architectur ...

  10. 一篇文章助你理解Python3中字符串编码问题

    前几天给大家介绍了unicode编码和utf-8编码的理论知识,以及Python2中字符串编码问题,没来得及上车的小伙伴们可以戳这篇文章:浅谈unicode编码和utf-8编码的关系和一篇文章助你理解 ...