GYM 101550 G.Game Rank(模拟)
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
分析:
一个游戏级别分2525级和额外等级LegendLegend,其中2525级最低级,11级次高级,LegendLegend最高级,每个级别对应一个星星数量,对应表如下:
• Rank 25-21: 2 stars
• Rank 20-16: 3 stars
• Rank 15-11: 4 stars
• Rank 10-1: 5 stars
规则如下:
W:rk大于等于6小于等于25且3连胜的话,star加2,否则加一
stai满了之后,晋级:比如23级,2颗星再加上两颗星就是22,两颗星!
L:rk大于20的话,输了也不掉star
rk小于等于20,且star!=0的话,减少一颗星
rk<20且star==0的话,掉级,star数等于改级star总数-1
写了很久啊,妈卖批,规则很模糊
code:
#include<iostream>
using namespace std;
int rk,star,flag;
void down()
{
if(rk>)
return ;
if(star)
{
star--;
return ;
}
if(rk<)
{
rk++;
if(rk>=&&rk<=)
star=;
else if(rk>=&&rk<=)
star=;
else if(rk>=&&rk<=)
star=;
}
}
void up(int v)
{
star+=v;
if(rk>=&&rk<=&&star>)
{
rk--;
star-=;
}else if(rk>=&&rk<=&&star>)
{
rk--;
star-=;
}else if(rk>=&&rk<=&&star>)
{
rk--;
star-=;
}else if(rk>=&&rk<=&&star>)
{
rk--;
star-=;
}
}
void f(string str)
{
int l=str.length();
for(int i=;i<l;i++)
{
if(rk==)
break;
if(str[i]=='W')
{
flag++;
if(rk>=&&flag>=)
{
up();
}else
{
up();
}
}else
{
down();
flag=;
}
}
}
int main()
{
string str;
while(cin>>str)
{
rk=,star=,flag=;//初始化
f(str);
if(rk)
{
cout<<rk<<endl;
}else
{
cout<<"Legend"<<endl;
}
}
return ;
}
GYM 101550 G.Game Rank(模拟)的更多相关文章
- Codeforces Gym 100269B Ballot Analyzing Device 模拟题
Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...
- 牛客小白月赛2 G 文 【模拟】
链接:https://www.nowcoder.com/acm/contest/86/G来源:牛客网 题目描述 Sεlιнα(Selina) 开始了新一轮的男友海选.她要求她的男友要德智体美劳样样都全 ...
- Codeforces Gym 100513G G. FacePalm Accounting
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...
- Codeforces Gym 100637G G. #TheDress 暴力
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...
- Codeforces Gym 100513G G. FacePalm Accounting 暴力
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...
- Gym 100646 Problem C: LCR 模拟题
Problem C: LCR 题目连接: http://codeforces.com/gym/100646/attachments Description LCR is a simple game f ...
- Gym - 101147G G - The Galactic Olympics —— 组合数学 - 第二类斯特林数
题目链接:http://codeforces.com/gym/101147/problem/G G. The Galactic Olympics time limit per test 2.0 s m ...
- Gym 100952 G. The jar of divisors
http://codeforces.com/gym/100952/problem/G G. The jar of divisors time limit per test 2 seconds memo ...
- Codeforces Gym 100203G G - Good elements 标记暴力
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
随机推荐
- Java性能调优-jstack-jstat-jmap
0. 必须在java进程的用户下执行 a). 先排查自己业务代码,再第三方的开源代码 b). 工具类都在jdk/bin目录下, 实现代码在tools.jar中 1. jstack-线程快照-死锁/阻塞 ...
- 简单的 shell 脚本 切分日志
为避免日志过大,需要按天分割日志,定时计划任务脚本如下: /data/shell/backup_yesterday_nginx_log.sh declare logs_path="/data ...
- 九度oj题目1153:括号匹配问题
题目1153:括号匹配问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4866 解决:2112 题目描述: 在某个字符串(长度不超过100)中有左括号.右括号和大小写字母:规定(与常见 ...
- 深入理解JavaScript系列(10):JavaScript核心(晋级高手必读篇)
本篇是ECMA-262-3 in detail系列的一个概述(本人后续会翻译整理这些文章到本系列(第11-19章).每个章节都有一个更详细的内容链接,你可以继续读一下每个章节对应的详细内容链接进行更深 ...
- 浅谈前端与SEO
转载地址: https://blog.csdn.net/lzm18064126848/article/details/53385274?tdsourcetag=s_pctim_aiomsg SEO(S ...
- java输出九九乘法口诀表
使用双重for循环输出九九乘法口诀表 public static void main(String[] args){ formula();} /** * for 循环实现9*9乘法口诀表 * &quo ...
- CMS API Overview - 翻译
source: http://activemq.apache.org/cms/cms-api-overview.html 1. CMS是啥? C++版本的API,用于收发消息(JMS). 如果您已熟悉 ...
- 移动端下滑刷新插件(jQuery插件)
由于在工作不能独自开发,而且为了给他们方便,自己写过不少的插件,不过今天刚好空闲,发出刚好完成的,移动端的下滑到底刷新插件.我不是很喜欢写插件给别人用,因为用起来自然是简单的,没什么难度,所以一起分享 ...
- swagger快速开发
转载:https://blog.csdn.net/xxoo00xx00/article/details/77163399 swagger 学习笔记 搭建环境: 1,jdk1.8 2,idea 3,sp ...
- CSS基础语法与选择器
CSS基础 语法 : <head> <style type="text/css"> 选择器(即修饰对象){ 修饰属性:属性值; 修饰属性:属性值; } &l ...