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的概 ...
随机推荐
- [App Store Connect帮助]六、测试 Beta 版本(1)TestFlight Beta 版测试概述(iOS、Apple TVOS、watchOS)
TestFlight Beta 版测试让您可以分发您 App 的 Beta 版构建版本给测试员并收集反馈.您可以在您的 App Store Connect 帐户中一次为至多 100 个 App 启用 ...
- java 实现word文档在线预览
一.准备工具 1.通过第三方工具openoffice,将word.excel.ppt.txt等文件转换为pdf文件 下载地址:http://www.openoffice.org/download/in ...
- event.target 属性返回哪个 DOM 元素触发了事件。
<ul> <li>list <strong>item 1</strong></li> <li><span>list ...
- 数学 FZU 2074 Number of methods
题目传送门 /* 数学:假设取了第i个,有C(n-1)(i-1)种取法 则ans = sum (C(n-1)(i-1)) (1<i<=n) 即2^(n-1) */ #include < ...
- TensorFlow---基础---GFile
使用TensorFlow的时候经常遇到 tf.gfile.exists().... 关于gfile,一个googler是这样给出的解释: The main roles of the tf.gfile ...
- 367 Valid Perfect Square 有效的完全平方数
给定一个正整数 num,编写一个函数,如果 num 是一个完全平方数,则返回 True,否则返回 False.注意:不要使用任何内置的库函数,如 sqrt.示例 1:输入: 16输出: True示例 ...
- 268 Missing Number 缺失的数字
给出一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数.案例 1输入: [3,0,1]输出: 2案例 2输入: [9,6,4,2,3,5,7, ...
- 查询编辑器便捷特性【MSSQL】
SQL Server团队为用户提供了一个便捷的特性 如果没有突出显示文本,那么按F5,执行整个批处理. 如果突出显示文本(选中SQL命令),那么只执行选中文本.
- redis之有序集合类型(Zset)——排行榜的实现
当数据库对排序支持的不是很好,可以利用redis有序集合排序 原文链接:http://blog.csdn.net/loophome/article/details/50373202
- 判断IE浏览器的类型以及提示信息(低版本浏览器不予显示)
//浏览器IE版本判断(function(window) { var theUA = window.navigator.userAgent.toLowerCase(); if ((theU ...