1 条题解
-
0
C++ :
#include <iostream> using namespace std; int main(){ //freopen("test6.in","r",stdin); string a,b; int la,lb,ai,bi,c,ans=0; cin>>a>>b; la=a.size(); lb=b.size(); for(int i=0;i<la;i++){ for(int j=0;j<lb;j++){ ai=i,bi=j,c=0; while(a[ai]==b[bi]&&c<min(la,lb)){ ai++;bi++; c++; } ans=max(ans,c); } } cout<<ans; return 0; }
Pascal :
var s,s2:string; a:array[1..100]of string; i,j,t,m,h,k,o:integer; begin readln(s);readln(s2);s:=s+s2; t:=length(s); for i:=1 to t-1 do begin m:=i+1; for j:=1 to m do a[j]:=copy(s,j,t-i); for h:=1 to m do for k:=1 to m do if (a[h]=a[k])and(h<>k) then begin o:=length(a[h]);writeln(o); exit;end; end; end.
- 1
信息
- ID
- 454
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者