Game Rank

Picture by Gonkasth on DeviantArt, cc by-nd

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 2525 regular ranks, and an extra rank, “Legend”, above that. The ranks are numbered in decreasing order, 2525 being the lowest rank, 11 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 66-2525, 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 11 or 22 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 11 star on the new rank.

If a player on rank 11-2020 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 2020(losing a game at rank 2020 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 2525-2121: 22 stars

  • Rank 2020-1616: 33 stars

  • Rank 1515-1111: 44 stars

  • Rank 1010-11: 55 stars

A player starts at rank 2525 with no stars. Given the match history of a player, what is her rank at the end of the sequence of matches?

Input

The input consists of a single line describing the sequence of matches. Each character corresponds to one game; ‘W’ represents a win and ‘L’ a loss. The length of the line is between 11 and 1000010000 characters (inclusive).

Output

Output a single line containing a rank after having played the given sequence of games; either an integer between 11 and 2525 or “Legend”.

Sample Input 1 Sample Output 1
WW
25
Sample Input 2 Sample Output 2
WWW
24
Sample Input 3 Sample Output 3
WWWW
23
Sample Input 4 Sample Output 4
WLWLWLWL
24
Sample Input 5 Sample Output 5
WWWWWWWWWLLWW
19
Sample Input 6 Sample Output 6
WWWWWWWWWLWWL
18

题意

25级升24级,要两颗星,但是不是两颗星满了升24,是3颗星才升级变成24级一星。然后24到23到……一直到20都是两颗星,然后3颗星 4颗星 5颗星,然后你20级以下是不掉级的,输了也不掉,如果你是20级0星不会掉星,但是20级一颗星就会掉,你掉级条件是,当前星数为0而且输了,那就掉级了,然后,他还有一个设定,如果在5级以下连胜三局或者以上,一局奖励两颗星,然后,一级是顶级,超过了一级就直接输出LEGEND,接下来那个人输成什么样都是LEGEND,其实就是炉石传说的规则

代码

#include<bits/stdc++.h>
using namespace std;
int k[] = {, , , , , , , , , , , , , , , , , , , , , , , , , };
char aa[];
int main() {
int n;
while (~scanf("%s", aa)) {
n = strlen(aa);
int ans = , b = ;
for (int i = ; i < n; i++) {
if (aa[i] == 'W') {
b++;
if (i > && aa[i - ] == 'W' && aa[i - ] == 'W' && ans >= )b++;
if (b > k[ans]) {
b -= k[ans]; ans--;
}
} else {
if (ans > || ans == && b == ) {
continue;
}
b--;
if (b < ) {
ans++; b = k[ans] - ;
}
}
if (ans == )break;
}
if (ans) {
printf("%d\n", ans);
} else {
puts("Legend");
}
}
return ;
}

最新文章

  1. AngularJS之代码风格36条建议【一】(九)
  2. android wifi 获取扫描结果
  3. 初涉SQL Server性能问题(2/4):列出等待资源的会话
  4. Linux下使用inode删除文件
  5. 一、Java语言基础
  6. 微软推荐的Get a code signing certificate流程和链接
  7. jquery处理页面元素
  8. SQL解决时间段重复合并问题
  9. Java开发之@PostConstruct和@PreDestroy注解
  10. python入门(五)
  11. 如何使用linux+xvfb+python+rfs+firefox+jenkins实现UI自动化
  12. 吴恩达Machine Learning 第一周课堂笔记
  13. linux shell 进阶篇、shell脚本编程-创建函数
  14. suctf逆向部分
  15. c# 登录 防止sql注入 mysql数据库
  16. spring整合mybatisXML版
  17. 学习mongoDB的网站
  18. Web视频播放之video.js
  19. Centos7 开启vsftpd
  20. redis 超时失效key 的监听触发

热门文章

  1. Git 基础教程 之 远程仓库
  2. 炒了8年的概念,到底该如何理解DevOps这个词?
  3. java.lang.Object 方法解析
  4. 【ACM】hdu_2115_I Love This Game_201308021517
  5. iOS 在 ARC 环境下 dealloc 的使用、理解误区
  6. Aizu/Aoj 0033 Ball
  7. 【cl】工程导入
  8. Java程序猿的JavaScript学习笔记(9—— jQuery工具方法)
  9. spark 决策树分类算法demo
  10. js重定向