RT
下面的代码是干啥的?
#include <iostream>
using namespace std;
int lps(string seq,int i,int j)
{
int len1,len2;
if(i==j)
{
return 1;
}
if(i>j)
{
return 0;
}
if(seq[i]==seq[j])
{
return lps(seq,i+1,j-1)+2;
}
len1=lps(seq,i,j-1);
len2=lps(seq,i+1,j);
if(len1>len2)
{
return len1;
}
return len2;
}
int main()
{
string seq;
cin>>seq;
int n=seq.size();
cout<<lps(seq,0,n-1)<<endl;
return 0;
}