CSU-2018
The gaming company Sandstorm is developing an online two player game. You have been asked to implement the ranking system. All players have a rank determining their playing strength which gets updated after every game played. There are 25 regular ranks, and an extra rank, “Legend”, above that. The ranks are numbered in decreas- ing order, 25 being the lowest rank, 1 the second highest rank, and Legend the highest rank.
Each rank has a certain number of “stars” that one needs to gain before advancing to the next rank. If a player wins a game, she gains a star. If before the game the player was on rank 6-25, and this was the third or more consecutive win, she gains an additional bonus star for that win. When she has all the stars for her rank (see list below) and gains another star, she will instead gain one rank and have one star on the new rank.
For instance, if before a winning game the player had all the stars on her current rank, she will after the game have gained one rank and have 1 or 2 stars (depending on whether she got a bonus star) on the new rank. If on the other hand she had all stars except one on a rank, and won a game that also gave her a bonus star, she would gain one rank and have 1 star on the new rank. If a player on rank 1-20 loses a game, she loses a star. If a player has zero stars on a rank and loses a star, she will lose a rank and have all stars minus one on the rank below. However, one can never drop below rank 20 (losing a game at rank 20 with no stars will have no effect).
If a player reaches the Legend rank, she will stay legend no matter how many losses she incurs afterwards. The number of stars on each rank are as follows:
• Rank 25-21: 2 stars
• Rank 20-16: 3 stars
• Rank 15-11: 4 stars
• Rank 10-1: 5 stars
A player starts at rank 25 with no stars. Given the match history of a player, what is her rank at the end of the sequence of matches?
Input
There will be several test cases. Each case consists of a single line describing the sequence of matches. Each character corre- sponds to one game; ‘W’ represents a win and ‘L’ a loss. The length of the line is between 1 and 10 000 characters (inclusive).
Output
Output a single line containing a rank after having played the given sequence of games; either an integer between 1 and 25 or “Legend”.
Sample Input
WW
WWW
WWWW
WLWLWLWL
WWWWWWWWWLLWW
WWWWWWWWWLWWL
Sample Output
25
24
23
24
19
18
Hint
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main ()
{
char s[11000];
while(~scanf("%s",s))
{
int len = strlen(s);
int star = 0;
int win = 0;
int rank = 25;
for (int i = 0; i < len; i++)
{
if (rank == 0)
{
break;
}
if (s[i] == 'W')
{
win ++;
star++;
if (win >= 3 && rank > 5)
star++;
if (rank<=25 && rank>=21 && star > 2)
{
rank--;
star-=2;
}
if (rank>=16 && rank<=20 && star > 3)
{
rank--;
star-=3;
}
if (rank>=11 && rank<=15 && star > 4)
{
rank--;
star-=4;
}
if (rank>=1 && rank<=10 && star > 5)
{
rank--;
star-=5;
}
}
else
{
win = 0;
if (rank>=21)
continue;
star --;
if (star < 0)
{
if (rank == 20)
{
star = 0;
}
if (rank>=15 && rank<=19)
{
rank++;
star = 2;
}
if (rank>=10 && rank<15)
{
rank++;
star = 3;
}
if (rank>=1 && rank<=9)
{
rank++;
star = 4;
}
}
}
}
if (!rank)
cout<<"Legend"<<endl;
else
cout<<rank<<endl;
}
return 0;
}
CSU-2018的更多相关文章
- CSU 2018年12月月赛 H(2220): Godsend
Description Leha somehow found an array consisting of n integers. Looking at it, he came up with a t ...
- CSU 2018年12月月赛 G(2219): Coin
Description 有这样一个众所周知的问题: 你面前有7个硬币,其中有一个劣质的(它比正常的硬币轻一点点),你有一个天平,问需要你需要使用天平多少次能保证找到那个劣质的硬币. 众所周知的算法是: ...
- CSU 2018年12月月赛 F(2218): Finding prime numbers
Description xrdog has a number set. There are 95 numbers in this set. They all have something in com ...
- CSU 2018年12月月赛 D 2216 : Words Transformation
Description There are n words, you have to turn them into plural form. If a singular noun ends with ...
- CSU 2018年12月月赛 B 2214: Sequence Magic
Description 有一个1到N的自然数序列1,2,3,...,N-1,N. 我们对它进行M次操作,每次操作将其中连续的一段区间 [Ai,Bi][Ai,Bi] (即第Ai个元素到第Bi个元素之间的 ...
- CSU 2018年12月月赛 A 2213: Physics Exam
Description 高中物理老师总认为给学生文本形式的问题比给纯计算形式的问题要求更高.毕竟,学生首先得阅读和理解问题. 因此,他们描述一个问题不像”U=10V,I=5A,P=?”,而是”有一个含 ...
- 2018. The Debut Album
http://acm.timus.ru/problem.aspx?space=1&num=2018 真心爱过,怎么能彻底忘掉 题目大意: 长度为n的串,由1和2组成,连续的1不能超过a个,连续 ...
- Math.abs(~2018),掌握规律即可!
Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...
- csu 1812: 三角形和矩形 凸包
传送门:csu 1812: 三角形和矩形 思路:首先,求出三角形的在矩形区域的顶点,矩形在三角形区域的顶点.然后求出所有的交点.这些点构成一个凸包,求凸包面积就OK了. /************** ...
- CSU 1503 点到圆弧的距离(2014湖南省程序设计竞赛A题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这 ...
随机推荐
- Servlet中response的相关案例(重定型,验证码,ServletContext文件下载)
重定向 首先设置状态码,设置响应头 //访问Demo1自动跳转至Demo2 //设置状态码 response.setStatus(302); //设置响应头 response.setHeader(&q ...
- MySQL每个分类的前几条记录
MySQL 获取所有分类和每个分类的前几条记录 比如有文章表 Article(Id,Category,InsertDate) 现在要用SQL找出每种类型中时间最新的前N个数据组成的集合 SELECT ...
- Mac上sonar插件的安装及使用
本文主要讲解sonar的安装及使用. 分为两个维度来讲解 1. 使用sonarqube以及自带的Derby数据库 2. 使用sonarqube以及配置mysql数据库 ---------------- ...
- bash:加减乘除(bc、let)
bc *. echo "$2 * $2" | bc > file let 如果只是 let a=1 和 a=1,它们没有区别,但是 let 还可以用于带赋值的运算,例如 le ...
- byteCTF 2019
本文作者:z3r0yu 由“合天智汇”公众号首发,未经允许,禁止转载! 0x00 前言 周末的比赛质量还是挺高的,特别是boring_code,有点烧脑但是做的就很开心. 0x01 boring_c ...
- 看了这篇Redis,我以大专生的身份,进入了阿里,定级P7
摘要: 前几天讲了Redis的面试知识点,当然那只是一部分,我相信各位在面试,或者实际开发过程中对缓存雪崩,穿透,击穿也不陌生吧,就算没遇到过但是你肯定听过,那三者到底有什么区别,我们又应该怎么去防止 ...
- flexpaper跨服务器访问swf不显示问题
在项目中使用flexpaper.html在线预览时,发现文件存放在本地localhost能访问,在服务器上的无法访问,通常报错“loadswf() is not defined” 研究发现是跨域问题导 ...
- 20191107-5 beta week 2/2 Scrum立会报告+燃尽图 04
此作业的要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/9957 一.小组情况 队名:扛把子 组长:孙晓宇 组员:宋晓丽 梁梦瑶 韩 ...
- Vue.js大屏数字滚动翻转效果
================================ 大屏数字滚动翻转效果来源于最近工作中element后台管理页面一张大屏的UI图,该UI图上有一个模块需要有数字往上翻动的效果,以下是最 ...
- 为宇宙第一强的IDE干一票
背景 在博客园看到很多人说.net在国内已死,很多人在为.net前途担忧,包括一些创业大佬也提及到这些问题,提及到客户指定了说使用php或者java. 那么基本可以确认了,.net 处于风雨漂泊的地位 ...