题目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. vue中axios的安装使用

    axios是一个基于 promise 的 HTTP 库,在vue中axios是比较常用的网络请求方法. 安装 npm install axios -S 在main.js配置 import axios ...

  2. Mysql fundamental knowledge

    Mysql 5.1, 5.5 are more stable than other versions. postgresql has more strict "sql standard &q ...

  3. ASP.NET Core 3.1+MySQL 部署到docker上面使用docker-compose+DockerFile

    一.新建DockerFile文件 选择Linux版本 FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base WORKDIR ...

  4. 再探CI,Github调戏Action手记——自动构建并发布到另一仓库

    前言 接上文初探CI,Github调戏Action手记--自动构建并发布 在学习了Action的基本操作之后 接着我们来探索Action其他可能的功能 众所周知 只有用得到的技术学习的才会最快 我也是 ...

  5. tf.nn.softmax_cross_entropy_with_logits 分类

    tf.nn.softmax_cross_entropy_with_logits(logits, labels, name=None) 参数: logits:就是神经网络最后一层的输出,如果有batch ...

  6. tf.nn.dropout 激活函数

    tf.nn.dropout(x,keep_prob,noise_shape=None,seed=None,name=None) 参数: x:一个浮点型Tensor. keep_prob:一个标量Ten ...

  7. cmake添加版本号

    vVersion.cmake文件内容如下: #vversion.cmake #vDateTime string(TIMESTAMP vDateTime "%Y%m%d-%H%M%S" ...

  8. 【乱码问题】IDEA控制台使用了GBK字符集

    什么Tomcat乱码设置IDEA的初始编码,瞎搞 终于在这个帖子看到了真相 https://blog.csdn.net/weixin_42617398/article/details/81806438 ...

  9. Daily Scrum 12/23/2015

    Process: Zhaoyang: Compile the Caffe IOS version and make it run in the IOS9. Yandong: Finish the Az ...

  10. Java前台传值至后台中文乱码

    记一次常见问题 今天导入了一个网上下载的项目,运行后发现,前台传值 到Servlet,Servlet保存至数据库,数据库保存的中文数据出现乱码,检查了一下表中的编码是utf8没错. 输出测试了一下 原 ...