codeforces 371c
#include<stdio.h>
int main() {
char s[200];
__int64 r,nb,ns,nc,pb,ps,pc,i,sum,tob,tos,toc;
while(scanf("%s",s)!=EOF) {
scanf("%I64d%I64d%I64d",&nb,&ns,&nc);
scanf("%I64d%I64d%I64d",&pb,&ps,&pc);
scanf("%I64d",&r);
sum=0;tob=0,toc=0,tos=0;
for(i=0;s[i];i++) {
if(s[i]=='B')
tob++;
if(s[i]=='S')
tos++;
if(s[i]=='C')
toc++;
}
sum=0;
while(1) {
if(tob==0) //
nb=0;
else {
if(nb>=tob)
nb-=tob;
else {
if(r/pb+nb>=tob) {
r=r-(tob-nb)*pb;
nb=0;
}
else
break;
}
}
if(tos==0)//
ns=0;
else {
if(ns>=tos)
ns-=tos;
else {
if(r/ps+ns>=tos) {
r=r-(tos-ns)*ps;
ns=0;
}
else
break;
}
}
if(toc==0)//
nc=0;
else {
if(nc>=toc)
nc-=toc;
else {
if(r/pc+nc>=toc) {
r=r-(toc-nc)*pc;
nc=0;
}
else
break;
}
}
sum++;
if(nb==0&&ns==0&&nc==0)//注意可能只有一种二种字母
break;
}
if(nb==0&&nc==0&&ns==0) {
r=r/(pb*tob+pc*toc+ps*tos);
sum+=r;
}
printf("%I64d\n",sum);
}
return 0;
}
codeforces 371c的更多相关文章
- CodeForces 371C Hamburgers
B题又耽误时间了...人太挫了.... C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes i ...
- CodeForces 371C Hamburgers(经典)【二分答案】
<题目链接> 题目大意: 给以一段字符串,其中只包含"BSC"这三个字符,现在有一定量免费的'B','S','C‘,然后如果想再买这三个字符,就要付出相应的价格.现在总 ...
- Codeforces 371C Hamburgers (二分答案)
题目链接 Hamburgers 二分答案,贪心判断即可. #include <bits/stdc++.h> using namespace std; #define REP(i,n) fo ...
- C++练习 | 二分练习
Codeforces 371C : Hamburgers #include<bits/stdc++.h> using namespace std; char B='B',S='S',C=' ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
随机推荐
- SpringBoot2.x版本整合SpringSecurity、Oauth2进行password认证
很多人在进行项目开发时都会用到Oauth2.0结合SpringSecurity或者Shiro进行权限拦截以及用户验证,网上也有很多的案例,前几天项目里边需要用到,顺便整合了进来,特此写篇博客,记录下过 ...
- 自定义View(10)*onSizeChanged,onMeasure,onDraw的注意事项及正确写法
1,onSizeChanged 触发: 当view的第一次分配大小或以后大小改变时的产生的事件. 工作: 计算绘制内容的位置,面积等相关值.避免每次在onDraw中计算了. 注意: 计算时不要忘记pa ...
- 国际化------international
1.配置web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=& ...
- Elasticsearch--扩展索引结构
目录 索引树形数据 索引非扁平数据 索引关系型数据 使用嵌套对象 评分与嵌套查询 使用主从关系 索引树形数据 使用path_analyzer分析树形数据字段 索引非扁平数据 数据如下: { " ...
- Set,Map与Array,Object对比
Map与Array 数据结构横向对比,用Map和Array分别实现最基本的增删改查: //增 { let theMap=new Map(); let theArray=[]; theMap.set(' ...
- 【sqli-labs】 less64 GET -Challenge -Blind -130 queries allowed -Variation3 (GET型 挑战 盲注 只允许130次查询 变化3)
双括号整型 http://192.168.136.128/sqli-labs-master/Less-64/?id=1)) or ((1
- 让ios支持http协议
ios默认只支持https协议,打开info.plist文件,加入以下设置 NSAppTransportSecurity NSAllowsArbitraryLoads
- ThinkPHP---thinkphp会话支持和文件载入
[一]会话控制 会话支持一般指cookie和session,在ThinkPHP里为了方便开发,封装了cookie和session方法. (1)session方法 在函数库封装了session方法 se ...
- 第一节:EasyUI样式,行内编辑,基础知识
一丶常用属性 $('#j_dg_left').datagrid({ url: '/Stu_Areas/Stu/GradeList', fit: true, // 自动适应父容器大小 singleSel ...
- 洛谷——P2158 [SDOI2008]仪仗队
P2158 [SDOI2008]仪仗队 找规律大水题嘛,如果你做过P1170 兔八哥与猎人 这题得到的规律是$a,b,c,d$,若$gcd(a-b,c-d)==1$ 那么$a,b$就能看到$c,d$ ...