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‘,然后如果想再买这三个字符,就要付出相应的价格.现在总 ...
随机推荐
- R语言学习——数据分析
complete.cases查看缺失值 箱图:
- 1076 Forwards on Weibo (30 分)
1076 Forwards on Weibo (30 分) Weibo is known as the Chinese version of Twitter. One user on Weibo ma ...
- boost实现日期时间格式化
#include <iostream> #include<thread> #include<chrono> #include<clocale> #inc ...
- cmd命令总结
1.进入d盘 2.命令运行D:\mongodb\bin中的mongod.exe 显示安装成功!(命令行下运行 MongoDB 服务器)
- 《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #18 向ext4转换
HACK #18 向ext4转换 ext4可以与ext2/ext3在后台进行互换.这里将介绍从ext2/ext3转换的方法以及转换时的注意事项.转换有两种方法可以将ext2/ext3的磁盘映像作为ex ...
- DOS 批处理命令For循环命令详解
for命令是一种对一系列对象依次循环执行同一个或多个命令的在命令行或批处理中运行的命令,结合一些Windows管理中的程序后,其处理功能强大.应用灵活方便程度令人刮目相看 for命令是一种对一系列 ...
- jieba库及wordcloud库的使用
知识内容: 1.jieba库的使用 2.wordcloud库的使用 参考资料: https://github.com/fxsjy/jieba https://blog.csdn.net/fontthr ...
- python 字体颜色的设置
实现过程: 终端的字符颜色是用转义序列控制的,是文本模式下的系统显示功能,和具体的语言无关. 转义序列是以ESC开头,即用\033来完成(ESC的ASCII码用十进制表示是27 ...
- WindowBrush
m_Element.Fill = SystemColors.WindowBrush; BorderBrush="{x:Static SystemColors.WindowBrush}&quo ...
- CSS 3栏自适应布局
绝对定位 css html,body{margin: 0px;height:100%;} div{height: 100%;} .left,.right {top: 0px;position: abs ...