Cod sursa(job #19234)

Utilizator izso88istvan zsolt izso88 Data 18 februarie 2007 22:49:28
Problema Reguli Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.98 kb
var t:text;
    vekt:array[1..500000] of double;
    a,e:double;
    n,i:longint;

function match(h:longint):boolean;
         var w,u,q:longint;
         begin
         w:=h+1;
         u:=0;
         q:=1;
         while (w<=n) and (u=0) do
          begin
           if vekt[w]<>vekt[q] then inc(u);
          inc(w);
          inc(q);
          if w mod h=1 then q:=1;
          end;

         if u=0 then match:=true
         else match:=false;
         end;



begin
     assign(t,'reguli.in');
     reset(T);
     read(t,n);

     read(t,e);
     for i:=2 to n do begin
                      read(t,a);
                      vekt[i-1]:=a-e;
                      writeln(a-e);
                      e:=a;
                      end;
     n:=n-1;
     close(T);
     i:=0;
     repeat
     inc(i);
     until match(i);

     assign(t,'reguli.out');
     rewrite(T);
     writeln(t,i);
     for n:=1 to i do writeln(t,vekt[n]:0:0);
     close(T);

end.