题目链接 Hamburgers

二分答案,贪心判断即可。

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i(0); i <  (n); ++i)
#define LL long long char str[1010];
LL len;
LL b, c, s, nb, nc, ns, pb, pc, ps;
LL money; bool judge(LL x){
LL mb = x * b;
LL ms = x * s;
LL mc = x * c; LL now_money = money;
if (mb > nb) now_money -= (mb - nb) * pb;
if (ms > ns) now_money -= (ms - ns) * ps;
if (mc > nc) now_money -= (mc - nc) * pc; return now_money >= 0LL;
} int main(){ scanf("%s", str);
len = strlen(str);
REP(i, len){
if (str[i] == 'B') ++b;
else if (str[i] == 'S') ++s;
else ++c;
} cin >> nb >> ns >> nc;
cin >> pb >> ps >> pc;
cin >> money; LL l = 0, r = 1e14;
while (l + 1 < r){
LL mid = (l + r) / 2;
if (judge(mid)) l = mid; else r = mid - 1;
} if (judge(r)) cout << r << endl; else cout << l << endl;
return 0; }

最新文章

  1. C#组合查询小Demo
  2. html画布
  3. C#多线程 线程池
  4. CURL学习和应用
  5. [Flex] PopUpButton系列——CornerRadius的运用
  6. Robolectric Test-Drive Your Android Code
  7. OCP-1Z0-051-题目解析-第14题
  8. 论JVM爆炸的几种姿势及自救方法
  9. ubuntu常用命令备忘
  10. 动态SQL2
  11. C# winform三种定时方法
  12. (转)Render Path
  13. spark-shell下有提示了,但是发现不能退格
  14. Solr导入MySQL数据之dataimport-handler
  15. random(随机模块)
  16. jQuery如何取得HiddenField值(转)
  17. Discuz论坛管理的问题汇总
  18. python 四种数值类型(int,long,float,complex)介绍
  19. Key Set---hud5363(快速幂)
  20. cf1060C. Maximum Subrectangle(思维 枚举)

热门文章

  1. 《鸟哥的Linux私房菜》学习笔记(0)——磁盘与文件系统管理
  2. python 闯关之路四(下)(并发编程与数据库编程) 并发编程重点
  3. java高级编程技巧
  4. Redis实现之AOF持久化
  5. 【面试】一篇文章帮你彻底搞清楚“I/O多路复用”和“异步I/O”的前世今生
  6. 【转】behave行为树学习使用第一天
  7. Mysql 死锁
  8. java主要集合类的数据结构学习
  9. 习题:八数码难题(双向BFS)
  10. PE