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/ ...
随机推荐
- kpw2使用心得
一:截屏 只需要同时按下对角线的两个点(比如左下角,右上角)就可以,图片可以通过数据线连接到电脑,在根目录下就可以查看截屏图片. 二:拖曳电子书pdf 可以通过数据线连接,找到kpw2的磁盘,将pdf ...
- CF 303C——Minimum Modular——————【剪枝】
Minimum Modular time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- 结合manage.py,在flask项目中使用websocket模块--- flask-socketio
前言: - 为什么我要使用 flask-socketio模块,而不是flask-sockets? - 因为flask-socketio与前端流行的websocket库socke ...
- CentOS安装nginx方法命令教程
1.依赖项和必要组件 yum install -y make cmake gcc gcc-c++ yum install -y pcre pcre-devel yum install -y zlib ...
- sql使用自连接去重复查询
查询公司与公司最新刷新的一条信息 select t1.userid,t1.id,t1.title,t1.RegType,t1.Salary,t1.SubjectID,t1.RefreshTime,t2 ...
- JS中的prototype(转载)
本文转载自博客园. 作者:叶剑锋 出处:http://www.cnblogs.com/yjf512/archive/2011/06/03/2071914.html 本文基于下面几个知识点: 1 原型法 ...
- 纯CSS的三角符号
项目中经常用到三角形,现在给大家讲下用纯CSS写的下三角实心图形 .triangle{ border-width: 5px 4px 0 4px; border-color: #454A7B trans ...
- 【网络编程】Socket套接字网络编程模型
一.Linux网络模型 -- Socket套接字编程 图片:Socket 抽象层 Socket编程--不同协议,统一接口 Socket的实质就是一个接口, 利用该接口,用户在使用不同的网络协议时,操作 ...
- 【Mood 21】要不要重复造轮子
90%的人应该使用另外10%的人制造的轮子 但是每个人都应该有能力去创造属于自己的轮子 使用不代表伸手拿来,使用也是需要学习的,使用也可以升级为创新,关键在于这个轮子是在谁的手中! 90%的能套用着别 ...
- JavaScript的数据类型与变量
JavaScript数据类型 1.原始数据类型: 数值型,如十进制数.十六进制数.八进制数和特殊值(Infinity.NaN),注意:NaN不能和自身比较 字符串型,如定界符.转义符: 布尔类型. 2 ...