#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的更多相关文章

  1. CodeForces 371C Hamburgers

    B题又耽误时间了...人太挫了.... C. Hamburgers time limit per test 1 second memory limit per test 256 megabytes i ...

  2. CodeForces 371C Hamburgers(经典)【二分答案】

    <题目链接> 题目大意: 给以一段字符串,其中只包含"BSC"这三个字符,现在有一定量免费的'B','S','C‘,然后如果想再买这三个字符,就要付出相应的价格.现在总 ...

  3. Codeforces 371C Hamburgers (二分答案)

    题目链接 Hamburgers 二分答案,贪心判断即可. #include <bits/stdc++.h> using namespace std; #define REP(i,n) fo ...

  4. C++练习 | 二分练习

    Codeforces 371C : Hamburgers #include<bits/stdc++.h> using namespace std; char B='B',S='S',C=' ...

  5. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  6. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  7. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  8. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  9. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

随机推荐

  1. bzoj题目大体分类

    http://m.blog.csdn.net/article/details?id=51387623

  2. C#+ItextSharp 查看pdf文件页面尺寸

    1# Nuget下载itextSharp,下载到本地 pm>Install-Package iTextSharp -Version 5.5.10 2# 引用dll,添加命名空间 using iT ...

  3. tp5增加验证的自定义规则

  4. Asp.Net 开发实战技术

    1.什么是WMI技术 WMI是一项核心的Windows管理技术,WMI作为一种规范和基础结构,通过它可以访问.配置.管理和监视几乎所有的Windows资源,比如用户可以在远程计算机器上启动一个进程:设 ...

  5. MongoDB Built-In Roles(内置角色)

    1. 数据库用户角色:read.readWrite; 2. 数据库管理角色:dbAdmin.dbOwner.userAdmin: 3. 集群管理角色:clusterAdmin.clusterManag ...

  6. 图论 HDOJ 5348 MZL's endless loop

    题目传送门 /* 题意:给一个n个点,m条边的无向图,要求给m条边定方向,使得每个定点的出入度之差的绝对值小于等于1. 输出任意一种结果 图论:一个图,必定存在偶数个奇度顶点.那么从一个奇度定点深搜, ...

  7. Visual Studio 相关

    基础配置: 背景色:豆沙绿(色调84 饱和度118 亮度205) 字体字号:Consolas 11号  离线下载方法: vs_enterprise.exe --layout c:\vs2017offl ...

  8. 四种IO模型

    四种 IO 模型:       首先需要明确,IO发生在 用户进程 与 操作系统 之间.可以是客户端IO也可以是服务器端IO. 阻塞IO(blocking IO):     在linux中,默认情况下 ...

  9. SuperSocket学习笔记(一)-一个完整的例子

    一.什么是SuperSocket 以下是作者的介绍 执行以下命令,获取SuperSocket项目 $ git clone https://github.com/kerryjiang/SuperSock ...

  10. Mysql阿里数据源配置参考

    maven pom.xml配置 <dependency> <groupId>com.alibaba</groupId> <artifactId>drui ...