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/ ...
随机推荐
- Unity3D之OnGUI知识总结
相对位置参考 http://blog.csdn.net/sunny__chen/article/details/51323265 自适应屏幕收缩 http://www.360doc.com/co ...
- IBM Rational Appscan Part 1
By Rohit T|July 23rd, 2012 http://resources.infosecinstitute.com/ibm-rational-appscan/ IBM Rational ...
- hdu 2845——Beans——————【dp】
Beans Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- 跨域策略文件crossdomain.xml文件
使用crossdomain.xml让Flash可以跨域传输数据 一.crossdomain.xml文件的作用 跨域,顾名思义就是需要的资源不在自己的域服务器上,需要访问其他域服务器.跨域策略文件 ...
- Hashtable元素的删除
2中方法 Remove(); Clear(); static void Main(string[] args) { Hashtable ht = new Hashtable(); ht.Add(1,& ...
- 05.while循环的练习
练习1: namespace _05.while循环练习01 { class Program { static void Main(string[] args) { //打印100次"努力学 ...
- 2017年10月30日 vs初级教学
Console.Write("Hello World!"); / / 插入 Hello World! Console.WriteLine("Hell ...
- Etcd入门教程
etcd是一个类似于zk的工具,用于保存值,节点-值这种映射关系的.节点组织结构类似unix文件系统结构,从/最开始.比如一个/test/name节点,值为guanxianseng.可以通过etcdc ...
- shutil模块——高级的文件、文件夹、压缩包处理模块
将文件内容拷贝到另一个文件 shutil.copyfileobj('fsrc', 'fdst', 'length') 方法源码: def copyfileobj(fsrc, fdst, length= ...
- sass函数:@function
sass定义了很多函数可供使用,当然你也可以自己定义函数,以@fuction开始. sass的官方函数链接为:sass fuction,实际项目中我们使用最多的应该是颜色函数,而颜色函数中又以ligh ...