题目链接:https://codeforces.com/contest/23/problem/A
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAXN=100+10;
char s[MAXN];
int ans;
int main()
{
scanf("%s",s);
for(int i=0;s[i];i++)
for(int j=i+1;s[j];j++)
for(int k=0;s[j+k];k++)
if(s[i+k]!=s[j+k]) break;
else ans=max(ans,k+1);
printf("%d\n",ans);
return 0;
}

该博客主要讨论了一种寻找字符串中最长重复子串的算法。通过遍历字符串并比较不同起始位置的子串,找出最长的相同部分。算法使用了三层循环,实现了高效的查找。

1814

被折叠的 条评论
为什么被折叠?



