题目1 : Magic Box
时间限制:10000ms

单点时限:1000ms

内存限制:256MB

描述

The circus clown Sunny has a magic box. When the circus is performing, Sunny puts some balls into the box one by one. The balls are in three colors: red(R), yellow(Y) and blue(B). Let Cr, Cy, Cb denote the numbers of red, yellow, blue balls in the box. Whenever the differences among Cr, Cy, Cb happen to be x, y, z, all balls in the box vanish. Given x, y, z and the sequence in which Sunny put the balls, you are to find what is the maximum number of balls in the box ever.

For example, let's assume x=1, y=2, z=3 and the sequence is RRYBRBRYBRY. After Sunny puts the first 7 balls, RRYBRBR, into the box, Cr, Cy, Cb are 4, 1, 2 respectively. The differences are exactly 1, 2, 3. (|Cr-Cy|=3, |Cy-Cb|=1, |Cb-Cr|=2) Then all the 7 balls vanish. Finally there are 4 balls in the box, after Sunny puts the remaining balls. So the box contains 7 balls at most, after Sunny puts the first 7 balls and before they vanish.

输入

Line : x y z

Line : the sequence consisting of only three characters 'R', 'Y' and 'B'. 

For % data, the length of the sequence is no more than .

For % data, the length of the sequence is no more than ,,  <= x, y, z <= .

输出
The maximum number of balls in the box ever.

提示

Another Sample

Sample Input Sample Output
0 0 0 RBYRRBY             4

样例输入

RRYBRBRYBRY

样例输出


  第一次使用hihoCoder,不了解怎么使用,吃了大亏。贴一下我事后写的代码,未经验证。

solution:

#include <iostream>
#include <string>
using namespace std;
int main()
{
int x,y,z;
string s;
while (cin>>x>>y>>z>>s)
{
int cr = , cy = , cb = ;
int res = ;
int tmp;
for (int i = ;i < s.size();++i)
{
if(s[i] == 'R')
cr++;
else if(s[i] == 'Y')
cy++;
else
cb++;
if(abs(cr-cy) != z)
continue;
if(abs(cy-cb) != x)
continue;
if(abs(cb-cr) != y)
continue;
tmp = cr + cy + cb;
if(res < tmp)
{
res = tmp;
cr = cy = cb = ;
}
}
tmp = cr + cy + cb;
if(res < tmp)
res = tmp;
cout<<res<<endl;
}
return ;
}

微软2016校园招聘在线笔试之Magic Box的更多相关文章

  1. 微软2016校园招聘在线笔试-Professor Q's Software

    题目2 : Professor Q's Software 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new softw ...

  2. 微软2016校园招聘在线笔试第二场 题目1 : Lucky Substrings

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A string s is LUCKY if and only if the number of different ch ...

  3. 微软2016校园招聘在线笔试 B Professor Q's Software [ 拓扑图dp ]

    传送门 题目2 : Professor Q's Software 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new s ...

  4. 微软2016校园招聘在线笔试 [Recruitment]

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A company plans to recruit some new employees. There are N ca ...

  5. 题目3 : Spring Outing 微软2016校园招聘在线笔试第二场

    题目3 : Spring Outing 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 You class are planning for a spring outin ...

  6. hihocoder 1288 : Font Size (微软2016校园招聘4月在线笔试)

    hihocoder 1288 笔试第一道..wa了好几次,也是无语..hihocoder错了不会告诉你失败的时候的测试集,这样有时候就很烦.. 遍历所有的字体,从min(w,h)开始逐渐变小开始遍历. ...

  7. 微软2016校园招聘4月在线笔试 A FontSize

    题目链接:http://hihocoder.com/problemset/problem/1288 分析:题目中所求的是最大的FontSize(记为S),其应该满足P*[W/S]*[H/S] > ...

  8. 微软2016校园招聘4月在线笔试 ABC

    题目链接:http://hihocoder.com/contest/mstest2016april1/problems 第一题:输入N,P,W,H,代表有N段文字,每段有ai个字,每行有⌊W/S⌋个字 ...

  9. 微软2016校园招聘4月在线笔试 hihocoder 1289 403 Forbidden

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描写叙述 Little Hi runs a web server. Sometimes he has to deny acces ...

随机推荐

  1. spark sql error mismatched input 'union' expecting { <EOF>,''................................

    给union的前后sql加括号就可以解决

  2. python3(二十七)property

    """ """ __author__ = 'shaozhiqi' # 绑定属性时,如果我们直接把属性暴露出去,虽然写起来很简单, # 但是, ...

  3. 怎么把jmeter汉化?

    1.在Jmeter 的bin目录下找到 jmeter.properties 文件 2.找到后复制一份出来用记事本打开,Ctrl+F输入 language 定位找到  #language=en  并且把 ...

  4. vueCli 运行报错

    error 如下: npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! shopping@0.1.0 serve: `vue-cli-service ...

  5. Problem L. World Cup

    题目大意:有A,B,C,D四个队伍,两两之间有一个比赛,假如A和B比赛,如果平局,各加一分,如果说A胜,给A加3分,不给B加分,B胜同理 给出A,B,C,D,的得分,判断形成这种局面有多少种方式. 思 ...

  6. 详解 Collection集合

    (请关注 本人"集合总集篇"博文--<详解 集合框架>) 首先,本人来讲解下 Collection集合的继承体系: Collection集合 的继承体系: Collec ...

  7. 9. 弹出键盘挡住input

    1.) react 中 <input className="inp3" placeholder="密码" type="password" ...

  8. Python 类学习的一些Tips

    这里不详细介绍类,只总结一些小萌新在学习python 类时会有的一些疑点. 类的私有性 在python中,属性和方法的访问权限只有两种,公开的,和私有的.在给属性命名时用两个“__”下划线作为开头,就 ...

  9. SpringCloud(七)超时、重试

    一.Ribbon(单独配置) 可以通过ribbon.xx来进行全局配置.也可以通过服务名.ribbon.xx来对指定服务配置 全局配置: ribbon: ConnectTimeout: 3000 #连 ...

  10. python 工具链 虚拟环境和包管理工具 pipenv

    Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, ...