You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).

Input

The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.

Output

Output one number — length of the longest substring that can be met in the string at least twice.

Example

Input
abcd
Output
0
Input
ababa
Output
3
Input
zzz
Output
2
找重复出现至少一次的最大子串长度
代码:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
#define Max 1001
using namespace std;
char s[]; int main()
{
cin>>s;
int d = ;
for(int i = ;i < strlen(s) - ;i ++)
{
for(int j = i + ;j < strlen(s);j ++)
{
int cnt = ;
while(j + cnt <strlen(s)&&s[i + cnt] == s[j + cnt])cnt ++;
if(d < cnt)d = cnt;
}
}
cout<<d<<endl;
}

最新文章

  1. java-JDBC从数据库中读取数据并进行日期民族男女的转换
  2. document对象
  3. 141. Linked List Cycle
  4. ubuntun pptpd
  5. mysql查看日志
  6. Windows下tuxedo配置
  7. 团体程序设计天梯赛-练习集L1-007. 念数字
  8. Subversion安装和使用
  9. Hive - 建表和加载数据指令小结 以及使用Load data指令的注意事项
  10. Objective-C中的内存管理——手动内存管理
  11. POJ 1064 Cable master(二分查找+精度)(神坑题)
  12. java.text.NumberFormat使用方法
  13. Redis学习-发布/订阅
  14. [SCOI 2016]美味
  15. Systemd 教程
  16. Django(十五)Form组件
  17. JSP 性能优化
  18. DOM常用事件绑定方式与实例
  19. JS高级-String-正则表达式:
  20. ECMAScript 6 Promise 对象

热门文章

  1. cygwin下安装软件
  2. PHP对象的使用,什么时候可以用中括号[], 什么时候可以用箭头-&gt;
  3. unity屏幕坐标转世界坐标结果为(0,0,0)
  4. vim 正则 捕获
  5. leetcode算法总结
  6. day20 project+查看新闻列表 + 点赞 + 图片验证码 + 评论和多级评论 + 后台管理 + webSocket + kindEditor
  7. Python不同版本切换
  8. MySQL修改字符集编码
  9. Neutron三层网络服务实现原理
  10. 【小米oj】找出单独的数字