比赛 暑假培训B班二测 评测结果 AAAWAAAAAA
题目名称 牛棚回声 最终得分 90
用户昵称 RT 运行时间 0.001 s
代码语言 Pascal 内存使用 0.17 MiB
提交时间 2012-07-22 09:05:24
显示代码纯文本
var
s1,s2:string;
i,j,k1,k2,p,q,x,y,max:integer;
ch1,ch2:array [1..81] of char;
begin
assign(input,'echo.in');
reset(input);
assign(output,'echo.out');
rewrite(output);
max:=0;
readln(s1);
readln(s2);
k1:=length(s1);
k2:=length(s2);
for i:=1 to 81 do begin
ch1[i]:=' '; ch2[i]:=' ';       
 end;
for i:=1 to k1 do
ch1[i]:=s1[i];
for i:=1 to k2 do
ch2[i]:=s2[i];

 x:=k1;
 y:=k2;
if x>y then x:=y;

for i:=1 to k1 do
begin
p:=1;
if ch2[1]=ch1[i] then begin
j:=i;
repeat
p:=p+1;
j:=j+1;
if (ch2[p]<>ch1[j])and(j<=x)and(p<=x) then
begin
max:=0;
break;
end;
if p>max then
max:=p;
until ch1[j+1]=' ';
end;
end;
j:=0;

for i:=1 to k2 do
begin
p:=1;
if ch1[1]=ch2[i] then begin
j:=i;
repeat
inc(j);
 inc(p);
if (ch1[p]<>ch2[j])and(j<=x)and(p<=x) then
begin
max:=0;
break;
end;
if p>max then max:=p;
until ch2[j+1]=' ';
end;
end;

write(max);
close(input);
close(output);
end.