Cod sursa(job #228685)

Utilizator nod_softwareBudisteanu Ionut Alexandru nod_software Data 7 decembrie 2008 20:02:47
Problema Prefix Scor 30
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.22 kb
//Vad ca te uiti la problema mea :P
program prefix_probl;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var p,i,j,n,m,t,c,Max:Longint;
    fin,fout:text;
    v:array [1..1000000] of char;
    ok,ok2:boolean;
{*------------------------------------*}
Function Prefix:Longint;
LABEL IESIRE;
begin
  max:=0;
  for i := 1 to n do
  begin
    ok:=true;
    j:=i;
    c:=0;

    while ok do//gasesc prefixe...
    Begin
      ok2:=True;
      for p := 1 to i do
        If v[j+p] <> v[p] then ok2:=False;

      if ok2 then inc(c)
      Else ok:=False;
      j:=j+i;

    End;

    if (C > 0) and (((I*(C+1))) < Max) then GOTO IESIRE;


    if (c > 0) and ((I*(C+1)) > Max) then
      Max:=I*(C+1);


  end;
  IESIRE:
  Prefix:=Max;
end;
{*------------------------------------*}
procedure citire;
var i:Longint;
begin
  assign(fin,'prefix.in'); reset(fin);
  assign(fout,'prefix.out'); rewrite(fout);

  readln(fin,t);
  for i := 1 to t do
  begin

    n:=0;
    while not eoln(fin) do
    begin
      inc(n);
      read(fin,v[n]);
    end;
    Readln(fin);

    Writeln(fout,Prefix);

  end;

  close(fin);
end;
{*------------------------------------*}
begin
  citire;
  close(fout);
end.