LSS

Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others)

Problem Description

Time flies, four years passed, colleage is over. When I am about to leave, a xuemei ask me an ACM  problem, but I can't solve it, I am 功力尽失.  Please help me so that I won't lose face in front of xuemei!

Give you a string , you should find the longest substring which is of the same character.

Input

First line there is a T , represents the test cases.

next T lines  will be T strings.

the length of every string is less than 100

all the characters of the strings will be lowercase letters

Output

for each test case output a number

Sample Input

1
a

Sample Output

1

Source

wuyiqi

Manager

 
  水题,求最长连续相同字符子串长度。
  就这么道破题纠结了我和旭旭一晚上,啊啊啊,脑子抽抽了,真不应该。无法很好的理解题意是大问题啊。这道题坑就坑在题目中提到的“字串”的含义应该是连续的,而我理解的字串应该是不连续的啊!像最长公共字串问题里面的字串不就是不连续的吗,有点凌乱了…… 总之卡在这么道题上,真给跪了,怨念无穷啊……
  题意:求最长连续相同字符子串长度。
  思路:从a[1]开始比较,每一个字符与它前面的字符比较如果相同,num加1,每次与sum比较,如果num>sum,令sum=num。最后输出sum。
  代码
 #include <iostream>

 using namespace std;

 int main()
{
int T,i;
cin>>T;
while(T--){
char a[];
cin>>a;
//统计最长连续相同字符子串长度
int num=,sum=;
for(i=;a[i];i++){
if(a[i]==a[i-])
num++;
else
num=;
if(num>sum)
sum=num;
}
cout<<sum<<endl;
}
return ;
}

Freecode : www.cnblogs.com/yym2013

Acdream 1111:LSS(水题,字符串处理)的更多相关文章

  1. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  2. ytu 1064: 输入三个字符串,按由小到大的顺序输出(水题,字符串处理)

    1064: 输入三个字符串,按由小到大的顺序输出 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 471  Solved: 188[Submit][Sta ...

  3. poj 1007:DNA Sorting(水题,字符串逆序数排序)

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 80832   Accepted: 32533 Des ...

  4. hdu 1106:排序(水题,字符串处理 + 排序)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  5. ytu 1052: 写一函数,将两个字符串连接(水题,指针练习)

    1052: 写一函数,将两个字符串连接 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 343  Solved: 210[Submit][Status][ ...

  6. 1222: FJ的字符串 [水题]

    1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1  =  “A” A2  =   ...

  7. 1001 字符串“水”题(二进制,map,哈希)

    1001: 字符串“水”题 时间限制: 1 Sec  内存限制: 128 MB提交: 210  解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...

  8. 暑假训练Round1——G: Hkhv的水题之二(字符串的最小表示)

    Problem 1057: Hkhv的水题之二 Time Limits:  1000 MS   Memory Limits:  65536 KB 64-bit interger IO format: ...

  9. sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

    n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you w ...

随机推荐

  1. bug-android之INSTALL_FAILED_NO_MATCHING_ABIS

    bug描述: 经常在网络上下载一些实例,自己研究 ,运行时不时会出现这个bug: Installation error: INSTALL_FAILED_NO_MATCHING_ABIS bug解决方案 ...

  2. TimeVal类——Live555源码阅读(一)基本组件类

    这是Live555源码阅读的第一部分,包括了时间类,延时队列类,处理程序描述类,哈希表类这四个大类. 这里是时间相关类的第一个部分. TimeVal类 TimeVal类定义在live555source ...

  3. HTK学习2:工具使用

    选自:http://www.cnblogs.com/mingzhao810/archive/2012/08/03/2617674.html 这个是重点,呵呵,本部分会讨论到如下内容: 1. 建立语音材 ...

  4. linux系统vsftpd登陆慢卡怎么办

    linux系统vsftpd登陆慢卡怎么办 浏览:145 | 更新:2013-12-31 00:50 vsftpd是linux系统中的一款ftp软件,用它可以实现文件,数据上传与下载,但有些用户会发现v ...

  5. 【Kubernetes】两篇文章 搞懂 K8s 的 fannel 网络原理

    近期公司的flannel网络很不稳定,花时间研究了下并且保证云端自动部署的网络能够正常work. 1.网络拓扑 拓扑如下:(点开看大图)  容器网卡通过docker0桥接到flannel0网卡,而每个 ...

  6. 怎样将myeclipse里默认编码设置成utf-8

    需要设置三个位置: [1]需要在  Preferences->general->content types->下角是文件编码,可以自己定义 [2]windows->Prefer ...

  7. 【leetcode】First Missing Positive

    First Missing Positive Given an unsorted integer array, find the first missing positive integer. For ...

  8. sqlite ORMLite 框架应用

    bean package com.test.deamo.bean; import android.os.Parcel; import android.os.Parcelable; import com ...

  9. ios 关于UIView 的multipleTouchEnabled 和 exclusiveTouch

    做项目时发现,在一个界面上的2个button竟然可以同时点击,依次push进去了2个 controller!我就产生了疑问,一个view的multipleTouchEnabled属性默认是false啊 ...

  10. cxGrid的使用方法

    来源 http://www.cnblogs.com/djcsch2001/archive/2010/07/19/1780573.html   1.  去掉GroupBy栏 cxGrid1DBTable ...