ACM:M: 1 VS 1
来源:互联网 发布:外汇指标软件视频 编辑:程序博客网 时间:2024/05/21 07:03
ACM:M: 1 VS 1
Description
Alice and Bob are playing the game SanguoSha 1VS1.If Alice take a card or use a card (it may be slash,missed,peach,duel,sabotage or theft and so on) or discard (sometimes he does not need to throw any card) we will write down an uppercase 'A', if Bob does this, of course, we will write down the letter 'B'. Tell me the length of the longest operation combo performed by either player.
Input
There are several test cases, each test case contains only a string composed of uppercaser 'A' and 'B'.The input will finish with the end of file.The length of the string is no more than 1000.
Output
For each the case, output an integer indicate for the length.
Sample Input
AAABBAAAAAAABBBBAAAAAAAAAA
Sample Output
548
感觉题目就是到处扯,其实就还是看最长的字符串长度。
#include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <cmath>#include <algorithm>#include <string>#include <ctime>#define LL long long#define MAX(a,b)((a)>(b)?a:b)#define MIN(a,b)((a)<(b)?a:b)#define INF 0x7ffffff#define N 1005#define M 15using namespace std;//char str[N];int main(){string str;while(cin>>str){
int max=0;int con=1;for(int i=0;i<str.length();i++){
if(str[i]==str[i+1]){
con++;
if(con>max)max=con;
}
elsecon=1;}
cout<<max<<endl;
}
return 0;}
阅读全文
0 0
- ACM:M: 1 VS 1
- acm-1-n之间能够被m整除的数的和
- 《ACM程序设计》 M题
- M-JPEG VS MPEG
- JPEG VS M-JPEG
- i5 540m vs i5 580m
- 【看书】while(m)m&=m-1,s++;的解释
- 《ACM 书中题目》 M
- ACM书中题目 M
- acm-1
- ACM 1
- acm 1
- ACM(1)
- M/M/1 队列系统模型
- opnet之self-m/m/1
- M$ Expression VS MM Studio
- M V C(1)
- 1-m-Two Sum
- UVA 120 Stacks of Flapjacks (煎饼)
- java泛型
- Servlet实现Filter过滤拦截
- 为什么读书
- Java进阶(四)线程间通信剖析
- ACM:M: 1 VS 1
- python类
- 两台主机布置lamp(php-fpm)
- 学习PHP注意事项
- Java并发编程--深入理解Semaphore
- 网络编程案例---有道字典应用
- ORB特征点提取
- Android中软键盘使用总结(一)
- Kotlin中的面向对象(二)