Cod sursa(job #266948)

Utilizator Cristian_BBerceanu Cristian Cristian_B Data 26 februarie 2009 13:14:15
Problema Subsir Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.59 kb
var a,b:array[1..500] of char;
    ct,ctmax,max,i,j,m,n:integer;
    f,g:text;
procedure load;
begin
assign(f,'subsir.in');
reset(f);
n:=0;
while not eoln(f) do
begin
inc(n);
read(f,a[n]);
end;
readln(f);
m:=0;
while not eoln(f) do
begin
inc(m);
read(f,b[m]);
end;
close(f);
assign(g,'subsir.out');
rewrite(g);
end;
BEGIN
load;
i:=0;
ctmax:=-1;
max:=-1;
while (i<=n) and (i<=m) do
begin
i:=i+1;
ct:=0;
 while (a[i]=b[i]) do
  begin
   ct:=ct+1; i:=i+1;
  end;
 if max<ct then max:=ct;
 if max=ct then ctmax:=ctmax+1;
end;
writeln(g,ctmax mod 666013);
close(g);
END.