题目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. Kitty-Cloud服务搭建过程剖析

    项目地址 https://github.com/yinjihuan/kitty-cloud 服务搭建 大家目前看到的都是我已经搭建好了的服务,如果让你从零开始自己搭建一个微服务的项目,要怎么做? 我们 ...

  2. Python爬虫系列(三):requests高级耍法

    昨天,我们更多的讨论了request的基础API,让我们对它有了基础的认知.学会上一课程,我们已经能写点基本的爬虫了.但是还不够,因为,很多站点是需要登录的,在站点的各个请求之间,是需要保持回话状态的 ...

  3. springboot httpsession.getAtt....is null

    1.开始怀疑是 @RequestMapping("") public String loginIndex() { return "admin/login"; } ...

  4. Golang Web入门(2):如何实现一个高性能的路由

    摘要 在上一篇文章中,我们聊了聊在Golang中怎么实现一个Http服务器.但是在最后我们可以发现,固然DefaultServeMux可以做路由分发的功能,但是他的功能同样是不完善的. 由Defaul ...

  5. Missing artifact net.sf.json-lib:json-lib:jar:2.2.3

    <!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib --><dependency> <gro ...

  6. spring boot 项目 mvn clean install 报 "Unable to find main class" 的解决方法

    按照步骤来总会解决的 检查pom.xml中是否加入了spring boot maven插件 <build> <plugins> <plugin> <group ...

  7. Chrome 浏览器安装 ChroPath 插件

    1.下载地址 http://www.cnplugins.com/devtool/chropath/download.html 2.安装方法 a.把下载的文件更改后缀名变为压缩包,然后解压到本地:如下图 ...

  8. Springboot:定时任务处理(十三)

    构建一个定时任务的service接口及实现(模拟) 接口:com\applesnt\springboot\service\TaskService.java package com.applesnt.s ...

  9. DataTable 与XML 交互

    一.将DataTable的内容写入到XML文件中 /// <summary> /// 将DataTable的内容写入到XML文件中 /// </summary> /// < ...

  10. s3cmd s3命令行工具

    Amazon S3 Tools: Command Line S3 Client Software and S3 Backup 官方网站