Codeforces Gym101522 C.Cheering-字符串 (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)
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
GOLSC
LSC
PCMSISTHEBEST
PCMS
PCMSWILLNEVERBEATLSC
Tie
ADDOILEVERYONE
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 }
Codeforces Gym101522 C.Cheering-字符串 (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)的更多相关文章
- Codeforces Gym101522 D.Distribution of Days-算日期 (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)
D.Distribution of Days The Gregorian calendar is internationally the most widely used civil calendar ...
- Codeforces Gym101522 A. Ambiguous Dates (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)
A. Ambiguous Dates There are two popular formats for representing a date: day/month/year or month/da ...
- gym101522 [小熊骑士限定]La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017
西瓜队(划掉),Kuma Rider久违的第一场训练,四小时瞎打.jpg A.水题,排序 #include<cstdio> #include<iostream> #includ ...
- Codeforces 176B (线性DP+字符串)
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=28214 题目大意:源串有如下变形:每次将串切为两半,位置颠倒形成 ...
- Codeforces 316G3 Good Substrings 字符串 SAM
原文链接http://www.cnblogs.com/zhouzhendong/p/9010851.html 题目传送门 - Codeforces 316G3 题意 给定一个母串$s$,问母串$s$有 ...
- Codeforces 1090B - LaTeX Expert - [字符串模拟][2018-2019 Russia Open High School Programming Contest Problem B]
题目链接:https://codeforces.com/contest/1090/problem/B Examplesstandard input The most famous characters ...
- CodeForces 1056E - Check Transcription - [字符串hash]
题目链接:https://codeforces.com/problemset/problem/1056/E One of Arkady's friends works at a huge radio ...
- codeforces 883H - Palindromic Cut - [字符串处理]
题目链接:http://codeforces.com/problemset/problem/883/H Time limit: 3000 ms Memory limit: 262144 kB Koly ...
- codeforces#1183H. Subsequences(字符串dp)
题目链接: http://codeforces.com/contest/1183/problem/H 题意: 给出一个长度为$n$的字符串,得到$k$个子串,子串$s$的花费是$n-|s|$ 计算最小 ...
随机推荐
- 8、python中的集合
集合是python中无序.可变的数据结构.集合与字典类似,集合中的元素必须是可哈希的(等同于字典中的键),也就是说集合中的元素是唯一.不可变的数据类型.这里前面说集合可变,后面又说集合中的元素不可变是 ...
- React基础(Diff算法,属性和状态)
1.React的背景原理 (1)React Diff算法流程 (2)React虚拟DOM机制 React引入了虚拟DOM(Virtual DOM)的机制:在浏览器端用Javascript实现了一套DO ...
- loj2091 「ZJOI2016」小星星
ref 总的来说,就是 容斥转化为点对应到点集问题. 树形 dp 解决转化后的问题. #include <iostream> #include <cstring> #inclu ...
- CSU-1908 The Big Escape
CSU-1908 The Big Escape Description There is a tree-like prison. Expect the root node, each node has ...
- [HTTPS]pfx转jks
keytool -importkeystore -srckeystore src.pfx -srcstoretype pkcs12 -destkeystore trg.jks -deststoret ...
- poj2002 hash+邻接表优化Squares
Squares Time Limit: 3500MS Memory Limit: 65536K Total Submissions: 17487 Accepted: 6643 Descript ...
- php开启子进程处理
$pageNum = ceil($totalNum/$pageSize); for($page=1;$page<=$pageNum;$page++){ $this->o_pcntl-> ...
- 求职之路(拿到百度、美团、趋势科技、华为offer)
求职之路(拿到百度.美团.趋势科技.华为offer) 版权所有:无缰之马chhuach(CSDN和博客源),转载请注明出处.CSDN地址http://blog.csdn.net/chhuach2005 ...
- 【BJOI 2019】奥术神杖
题意 你有一个长度为 $n$ 的模板串(由 $0-9$ 这 $10$ 个数字和通配符 $.$ 组成),还有 $m$ 个匹配串(只由 $0-9$ 这 $10$ 个数字组成),每个匹配串有一个魔力值 $v ...
- tableView镶嵌加入CollectionView实现方法
创建一个继承UICollectionView的类QHCollectionView在QHCollectionView.h中添加接口方法 @interface QHCollectionView : UIC ...