Hamburgers
Hamburgers
http://codeforces.com/problemset/problem/371/C
1 second
256 megabytes
standard input
standard output
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (bread), 'S' (sausage) и 'C' (cheese). The ingredients in the recipe go from bottom to top, for example, recipe "ВSCBS" represents the hamburger where the ingredients go from bottom to top as bread, sausage, cheese, bread and sausage again.
Polycarpus has nb pieces of bread, ns pieces of sausage and nc pieces of cheese in the kitchen. Besides, the shop nearby has all three ingredients, the prices are pb rubles for a piece of bread, ps for a piece of sausage and pc for a piece of cheese.
Polycarpus has r rubles and he is ready to shop on them. What maximum number of hamburgers can he cook? You can assume that Polycarpus cannot break or slice any of the pieces of bread, sausage or cheese. Besides, the shop has an unlimited number of pieces of each ingredient.
The first line of the input contains a non-empty string that describes the recipe of "Le Hamburger de Polycarpus". The length of the string doesn't exceed 100, the string contains only letters 'B' (uppercase English B), 'S' (uppercase English S) and 'C' (uppercase English C).
The second line contains three integers nb, ns, nc (1 ≤ nb, ns, nc ≤ 100) — the number of the pieces of bread, sausage and cheese on Polycarpus' kitchen. The third line contains three integers pb, ps, pc (1 ≤ pb, ps, pc ≤ 100) — the price of one piece of bread, sausage and cheese in the shop. Finally, the fourth line contains integer r (1 ≤ r ≤ 1012) — the number of rubles Polycarpus has.
Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64dspecifier.
Print the maximum number of hamburgers Polycarpus can make. If he can't make any hamburger, print 0.
BBBSSC
6 4 1
1 2 3
4
2
BBC
1 10 1
1 10 1
21
7
BSC
1 1 1
1 1 3
1000000000000
200000000001
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<queue>
#include<map>
#include<stack>
typedef long long ll;
using namespace std; ll a,b,c,d,e,f;
ll S,B,C;
ll num;
bool erfen(ll mid){
ll SS=mid*S-b;
if(SS<) SS=;
ll BB=mid*B-a;
if(BB<) BB=;
ll CC=mid*C-c;
if(CC<) CC=;
ll tmp=SS*e+BB*d+CC*f;
if(tmp>num) return false;
return true;
} int main(){ string str;
cin>>str; for(int i=;i<str.length();i++){
if(str[i]=='S') S++;
else if(str[i]=='B') B++;
else C++;
}
cin>>a>>b>>c>>d>>e>>f>>num;
ll L=,R=1e15,mid;
while(L<=R){
mid=L+R>>;
if(erfen(mid)){
L=mid+;
}
else{
R=mid-;
}
}
cout<<R<<endl; }
Hamburgers的更多相关文章
- Codeforces Round #218 (Div. 2) C. Hamburgers
		
C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes input standard input ...
 - CodeForces 371C Hamburgers
		
B题又耽误时间了...人太挫了.... C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes i ...
 - B - Hamburgers
		
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own han ...
 - Codeforces 371C Hamburgers (二分答案)
		
题目链接 Hamburgers 二分答案,贪心判断即可. #include <bits/stdc++.h> using namespace std; #define REP(i,n) fo ...
 - C. Hamburgers
		
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own han ...
 - 二分搜索 Codeforces Round #218 (Div. 2) C. Hamburgers
		
题目传送门 /* 题意:一个汉堡制作由字符串得出,自己有一些原材料,还有钱可以去商店购买原材料,问最多能做几个汉堡 二分:二分汉堡个数,判断此时所花费的钱是否在规定以内 */ #include < ...
 - H	Kuangyeye and hamburgers
		
链接:https://ac.nowcoder.com/acm/contest/338/H来源:牛客网 题目描述 Kuangyeye is a dalao of the ACM school team ...
 - cf C. Hamburgers
		
http://codeforces.com/contest/371/problem/C 二分枚举最大汉堡包数量就可以. #include <cstdio> #include <cst ...
 - CodeForces 371C Hamburgers(经典)【二分答案】
		
<题目链接> 题目大意: 给以一段字符串,其中只包含"BSC"这三个字符,现在有一定量免费的'B','S','C‘,然后如果想再买这三个字符,就要付出相应的价格.现在总 ...
 
随机推荐
- 学习笔记之Visual Studio Team Services
			
VSTS and TFS Documentation | Microsoft Docs https://docs.microsoft.com/en-us/vsts/index?view=vsts#pi ...
 - selenium java-3 定位元素的八种方法
			
web driver提供了八种元素定位的方法: id name class name tag name link text partial link text xpath css selector 如 ...
 - testNG断言
			
https://junit.org/junit4/javadoc/latest/org/junit/Assert.html#assertThat 断言:Hamcrest - Matchers 对象: ...
 - LightGBM优势总结
			
效率和内存上的提升 1) 在训练决策树计算切分点的增益时,xgboost采用预排序,即需要对每个样本的切分位置都要计算一遍,所以时间复杂度是O(#data). 而LightGBM则是将样本离散化为直方 ...
 - Spring MVC   底层原理
			
参考博客:http://www.cnblogs.com/xiaoxi/p/6164383.html Spring MVC处理的流程: 具体执行步骤如下: 1 首先用户发送请求给前端控制器,前端控制器根 ...
 - Web 下载图片为空
			
问题描述: 文件下载功能是web开发中经常使用到的功能,使用HttpServletResponse对象就可以实现文件的下载.但是下载任务正常进行,下载下来的图片却是空 问题代码: //从服务器下载一张 ...
 - C# 获取物理网卡Mac地址
			
// <summary> /// 获取网卡物理地址 /// </summary> /// <returns></returns> public stat ...
 - tensorflow data's save and load
			
note: if you'll load data,the data shape should be similar with saved data's shape. -- 中式英语,天下无敌 ...
 - [Flutter] 支持描边效果的Text
			
新版的flutter已经自带这个功能了.TextSyle 中一个shadow . 目前flutter中没找到很好的办法给Text增加描边.自己扩展了一个TextEx,可以实现简单的描边效果,能满足大部 ...
 - xe7 控件升级
			
rm.ehlib.synedit OK SynSQLSyn1->TableNames 为NULL,导致添加数据失败,XE6正常 放在按钮里也不正常,就不说初始化次序引起的.