Pagini recente » Cod sursa (job #1136779) | Cod sursa (job #2218060) | Cod sursa (job #105113) | Cod sursa (job #1981535) | Cod sursa (job #18241)
Cod sursa(job #18241)
const
lim=500500;
var
pi,t:array[1..lim] of int64;
i,j,n,m,k,x,y,q:longint;
procedure prefix;
begin
m:=n;
pi[1]:=0;
k:=0;
for q:=2 to m do
begin
while (k>0) and (t[k+1]<>t[q]) do k:=pi[k];
if t[k+1]=t[q] then inc(k);
pi[q]:=k;
end;
end;
begin
assign(input,'reguli.in');
reset(input);
readln(n);
readln(x);
for i:=2 to n do
begin
readln(y);
t[i-1]:=y-x;
x:=y;
end;
close(input);
dec(n);
prefix;
assign(output,'reguli.out');
rewrite(output);
writeln(n-pi[n]);
for i:=1 to n-pi[n] do
writeln(t[i]);
close(output);
end.