Codeforces Gym101522 C.Cheering-字符串 (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)...

 

C.Cheering

 

To boost contestants' performances in the 20th La Salle - Pui Ching Programming Challenge, the organizers have bought N robots to cheer for them. Each robot is supposed to display cheering slogans, letter by letter.

Unfortunately, due to some technical reasons, the display screen of each robot can only display one fixed character. Therefore, the organizers decided to arrange the robots in a row, thus forming a string of N letters (What a waste!). All letters are in uppercase.

The two hosting schools have abbreviated names LSC and PCMS, as we all know. Which of the two names appear (as a substring) in the string more often?

Input

The first and only line of input consists of a string with N uppercase letters.

For all test cases, N ≤ 100.

Output

Let A be the number of occurrences of LSC in the given string.

Let B be the number of occurrences of PCMS in the given string.

If A > B, output LSC.

If A < B, output PCMS.

If A = B, output Tie.

Example

Input
GOLSC
Output
LSC
Input
PCMSISTHEBEST
Output
PCMS
Input
PCMSWILLNEVERBEATLSC
Output
Tie
Input
ADDOILEVERYONE
Output
Tie


代码:

 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 #include<cmath>
 5 #include<algorithm>
 6 using namespace std;
 7 const int N=1e5+10;
 8 char s[N];
 9 int main(){
10     memset(s,0,sizeof(s));
11     while(~scanf("%s",s)){ 12 int len=strlen(s); 13 int num1=0,num2=0; 14 for(int i=0;i<len;i++){ 15 if(s[i]=='L'){ 16 if(s[i+1]=='S'&&s[i+2]=='C'&&i+2<len)num1++; 17  } 18 if(s[i]=='P'){ 19 if(s[i+1]=='C'&&s[i+2]=='M'&&s[i+3]=='S'&&i+3<len)num2++; 20  } 21  } 22 if(num1>num2)printf("LSC\n"); 23 else if(num1<num2)printf("PCMS\n"); 24 else printf("Tie\n"); 25  } 26 return 0; 27 }

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/ZERO-/p/9702897.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值