Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program z1;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- var
- n, i, h: integer;
- a: array [1..1000] of integer;
- d: array [1..1000] of integer;
- function test(t: integer): boolean;
- var
- i: integer;
- r: array [1..1000] of integer;
- begin
- r[1] := a[1];
- for i := 2 to n + 1 do
- r[i] := r[i - 1] * t + a[i];
- if (r[n + 1] = 0) then
- begin
- for i := 1 to n + 1 do
- a[i] := r[i];
- dec(n);
- end;
- test := (r[n+2] = 0) and (n <> -1);
- end;
- procedure del;
- var
- f, i: integer;
- begin
- f := a[n + 1];
- for i := trunc(sqrt(f)) downto 2 do
- if(f mod i = 0) then
- while (f mod i = 0) and test(-f div i) do
- begin
- inc(h);
- d[h] := -f div i;
- end;
- for i := trunc(sqrt(f)) downto 2 do
- if(f mod i = 0) then
- while (f mod i = 0) and test(-i) do
- begin
- inc(h);
- d[h] := -i;
- end;
- while(test(-1)) do
- begin
- inc(h);
- d[h] := -1;
- end;
- while(test(1)) do
- begin
- inc(h);
- d[h] := 1;
- end;
- for i := 2 to trunc(sqrt(f)) do
- if(f mod i = 0) then
- while (f mod i = 0) and test(f) do
- begin
- inc(h);
- d[h] := f;
- end;
- for i := 2 to trunc(sqrt(f)) do
- if(f mod i = 0) then
- while (f mod i = 0) and test(f div i) do
- begin
- inc(h);
- d[h] := f div i;
- end;
- end;
- begin
- readln(n);
- for i := 1 to n + 1 do read(a[i]);
- del;
- for i := 1 to h - 1 do write(d[i], ' ');
- writeln(d[h]);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement