Pagini recente » Cod sursa (job #2034915) | Cod sursa (job #366246) | Cod sursa (job #2152236) | Cod sursa (job #2826398) | Cod sursa (job #18461)
Cod sursa(job #18461)
const max=500000;
var v:array[0..max] of int64;
j,i,n:longint;nel,el:int64;
function serios(i:int64):boolean;
var a,j:longint;
begin
v[0]:=v[i];
serios:=true;
for j:=i+1 to n-1 do
begin
if v[j]<>v[j mod i] then serios:=false;
end;
end;
function lavrajala(i:longint):boolean;
var a,j:longint;
begin
v[0]:=v[i];
lavrajala:=true;
if n-i<50 then exit
else
for j:=1 to 50 do
begin
a:=random(n-i-2)+1;
if v[i+a]<>v[a mod i] then lavrajala:=false;
end;
end;
begin
assign(input,'reguli.in');
reset(input);
readln(n);
readln(el);
for i:=1 to n-1 do
begin
readln(nel);
v[i]:=nel-el;
el:=nel;
end;
assign(output,'reguli.out');
rewrite(output);
for i:=1 to n-2 do
if lavrajala(i) then
if serios(i) then
begin
writeln(i);
for j:=1 to i do
writeln(v[j]);
close(output);
exit;
end;
writeln(n-1);
for j:=1 to n-1 do
writeln(v[j]);
close(output);
exit;
end.