问题不大。
字符串匹配什么的 感觉用STL里面的find函数棒极了。
真香
find(a,b)函数查找 在a里面查找b串
成功就返回a里面找到的indexb的索引 找不到就返回-1
/*
qq:1239198605
ctgu_yyf
*/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
string a,aa,aaa,aaaa,t;
int main()
{
ios::sync_with_stdio(false);
//cout<<"123"<<endl;
cin>>a;
t="";
int k=1;
//cout<<"123"<<endl;
while(a.size()>=3&&k<=a.size()-1)
{
aa=a.substr(0,k);
aaa=a.substr(a.size()-k,k);
if(aa==aaa)
{
aaaa=a.substr(1,a.size()-2);//除去首尾两个字母的字符串
if(aaaa.find(aa)!=-1)
{
t=aa;
}
}
k++;
}
// cout<<"1234"<<endl;
if(t=="")
cout<<"Just a legend"<<endl;
else
{
cout<<t<<endl;
}
return 0;
}