Advertisement
savrasov

ftghfgh

Jan 31st, 2017
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. program z1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. var
  9. n, i, h: integer;
  10. a: array [1..1000] of integer;
  11. d: array [1..1000] of integer;
  12.  
  13. function test(t: integer): boolean;
  14. var
  15. i: integer;
  16. r: array [1..1000] of integer;
  17. begin
  18. r[1] := a[1];
  19. for i := 2 to n + 1 do
  20. r[i] := r[i - 1] * t + a[i];
  21. if (r[n + 1] = 0) then
  22. begin
  23. for i := 1 to n + 1 do
  24. a[i] := r[i];
  25. dec(n);
  26. end;
  27. test := (r[n+2] = 0) and (n <> -1);
  28. end;
  29.  
  30. procedure del;
  31. var
  32. f, i: integer;
  33. begin
  34. f := a[n + 1];
  35. for i := trunc(sqrt(f)) downto 2 do
  36. if(f mod i = 0) then
  37. while (f mod i = 0) and test(-f div i) do
  38. begin
  39. inc(h);
  40. d[h] := -f div i;
  41. end;
  42. for i := trunc(sqrt(f)) downto 2 do
  43. if(f mod i = 0) then
  44. while (f mod i = 0) and test(-i) do
  45. begin
  46. inc(h);
  47. d[h] := -i;
  48. end;
  49. while(test(-1)) do
  50. begin
  51. inc(h);
  52. d[h] := -1;
  53. end;
  54. while(test(1)) do
  55. begin
  56. inc(h);
  57. d[h] := 1;
  58. end;
  59. for i := 2 to trunc(sqrt(f)) do
  60. if(f mod i = 0) then
  61. while (f mod i = 0) and test(f) do
  62. begin
  63. inc(h);
  64. d[h] := f;
  65. end;
  66. for i := 2 to trunc(sqrt(f)) do
  67. if(f mod i = 0) then
  68. while (f mod i = 0) and test(f div i) do
  69. begin
  70. inc(h);
  71. d[h] := f div i;
  72. end;
  73. end;
  74.  
  75. begin
  76. readln(n);
  77. for i := 1 to n + 1 do read(a[i]);
  78. del;
  79. for i := 1 to h - 1 do write(d[i], ' ');
  80. writeln(d[h]);
  81. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement