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

【题意】

在这里输入题意

【题解】

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;
}

最新文章

  1. 第三十章 elk(1) - 第一种架构(最简架构)
  2. python-print
  3. 数据库连接池dbcp基本配置
  4. Java String字符串/==和equals区别,str。toCharAt(),getBytes,indexOf过滤存在字符,trim()/String与StringBuffer多线程安全/StringBuilder单线程—— 14.0
  5. Unit Of Work--工作单元(二)
  6. Keepalived 使用指南
  7. 【转】Unity3D的输入(Input)——键盘和鼠标
  8. 转:SELENIUM TIPS: CSS SELECTORS
  9. linux下用core和gdb查询出现&quot;段错误&quot;的地方【转】
  10. Base64加密解密原理以及代码实现(VC++)
  11. 怎么利用ultraISO对一个文件夹制作ISO镜像
  12. asp 正则替换函数
  13. Swift 2.2 协议和代理
  14. 如何开发一个chrome扩展
  15. python 将mysql数据库中的int类型修改为NULL 报1366错误,解决办法
  16. leetcode-69.x的平方根
  17. Scrapy实现腾讯招聘网信息爬取【Python】
  18. Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -
  19. dubbo+spring_maven 遇到的问题 Error creating bean with name &#39;***&#39;: Instantiation of bean failed;
  20. Vue组件基础

热门文章

  1. Crytek的幕后花絮
  2. Delphi的时间 x87 fpu control word 精度设置的不够
  3. angularjs 自定义服务
  4. ubuntu SDK 安装
  5. vijos--P1211--生日日数(纯模拟)
  6. 7. 关于IntelliJ IDEA删除项目
  7. 如何配置MySQL?(三)
  8. HUE搭配基础
  9. rails 开发随手记 9
  10. UWP开发小结