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

【题意】

在这里输入题意

【题解】

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. 管理ONS(Oracle Notification Service)

    Onsctl Onsctl这个命令是用来管理ONS(Oracle Notification Service)是OracleClustser实现FAN Event Push模型的基础. Oracle N ...

  2. Oracle单实例情况下的library cache pin的问题模拟与问题分析

    Oracle单实例情况下的library cache pin的问题模拟与问题分析 參考自: WAITEVENT: "library cache pin" Reference Not ...

  3. jquery去重

    <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title> ...

  4. BZOJ 4551 HEOI 2016 树 (并查集)

    思路: 考虑时光倒流 这不就是并查集裸题了-----. //By SiriusRen #include <cstdio> #include <cstring> #include ...

  5. UI Framework-1: Aura Focus and Activation

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

  6. Embedding Flash Fullscreen in the Browser Window

    For Developers‎ > ‎Design Documents‎ > ‎ Embedding Flash Fullscreen in the Browser Window Auth ...

  7. 紫书 例题 10-15 UVa 1638(递推)

    从大到小安排杆子 分三种情况 (1)插到最左边,那么左边看到了杆子会多一个 (2)插到最右边,那么右边看到了杆子会多一个 (3)插到中间边,那么不影响左边和右边看到的杆子数 具体看代码 #includ ...

  8. ruby redis的集群管理器

    #========================================================================================== # => ...

  9. java中hashmap和hashtable和hashset的区别

    hastTable和hashMap的区别:(1)Hashtable是基于陈旧的Dictionary类的,HashMap是Java 1.2引进的Map接口的一个实现.(2)这个不同即是最重要的一点:Ha ...

  10. error:assign attribute must be unsafeunretained

    今天在使用协议的过程中.偶然发现这样使用 ? 1 2 3 4 5 6 7 8 9 10 @interface AppDelegate (){     id<chatdelegate>  t ...