Pagini recente » Cod sursa (job #1231769) | Cod sursa (job #1523954) | Cod sursa (job #1765685) | Cod sursa (job #202410) | Cod sursa (job #1819061)
USES Math;
CONST
tfi = 'reguli.in';
tfo = 'reguli.out';
VAR
fi,fo : text;
n : longint;
a,b : array[0..500010] of int64;
z : array[0..500010] of longint;
Procedure inp;
Var
i: longint;
Begin
Read(fi,n);
For i:=1 to n do read(fi,b[i]);
dec(n);
For i:=1 to n do a[i]:=b[i+1]-b[i];
End;
Procedure init;
Var
i,j,l,r: longint;
Begin
l:=1; r:=1;
z[1]:=n;
For i:=2 to n do
If i>r then
begin
l:=i; r:=i;
While (r<=n) and (a[r-l+1]=a[r]) do inc(r);
z[i]:=r-l;
dec(r);
end
else
begin
j:=i-l+1;
If z[j]<r-i+1 then z[i]:=z[j]
else
begin
l:=i;
While (r<=n) and (a[r-l+1]=a[r]) do inc(r);
z[i]:=r-l;
dec(r);
end;
end;
End;
Procedure sub2;
Var
i,l,res: longint;
Begin
res:=0;
For i:=1 to n do
If z[i+1]=n-i then
begin
res:=i;
break;
end;
writeln(fo,res);
For i:=1 to res do writeln(fo,a[i]);
End;
BEGIN
assign(fi,tfi); reset(fi);
assign(fo,tfo); rewrite(fo);
inp;
init;
sub2;
close(fi); close(fo);
END.