Pagini recente » Cod sursa (job #2564205) | Cod sursa (job #1487205) | Cod sursa (job #3261777) | Cod sursa (job #1607293) | Cod sursa (job #19381)
Cod sursa(job #19381)
const
lim=500500;
var
t:array[1..lim] of int64;
pi:array[1..lim] of longint;
i,n,m,k,q:longint;
x,y:int64;
procedure prefix;
begin
pi[1]:=0;
k:=0;
for q:=2 to n 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);
m:=n-pi[n];
writeln(m);
for i:=1 to m do
writeln(t[i]);
close(output);
end.