Guest User

Untitled

a guest
Jun 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. program w17;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. var
  9. a,b: array[1..35000] of integer;
  10. i,min,max,j,n,t: integer;
  11. eq: boolean;
  12. begin
  13. { TODO -oUser -cConsole Main : Insert code here }
  14. min:=35000;
  15. max:=0;
  16.  
  17. reset(input,'input.txt');
  18. rewrite(output,'output.txt');
  19.  
  20. read(n);
  21. dec(n);
  22.  
  23. for i:=1 to 35000 do
  24. b[i]:=0;
  25.  
  26. for i:=1 to n do
  27. begin
  28. read(a[i]);
  29. inc(b[a[i]]);
  30. if a[i]>max then
  31. max:=a[i];
  32. end;
  33.  
  34. for i:=1 to max do
  35. if (b[i]<min)and(b[i]<>0) then
  36. min:=b[i];
  37.  
  38. if min=n then
  39. write(output,'1')
  40. else
  41. for i:=min downto 1 do
  42. begin
  43. if (min mod i = 0)and(n mod i = 0) then
  44. for t:=1 to i-1 do
  45. begin
  46. eq:=true;
  47. for j:=1 to (n div i) do
  48. if a[j]<>a[t*((n div i)+j)] then
  49. eq:=false;
  50. end;
  51.  
  52. if i=1 then
  53. begin
  54. write(output,n);
  55. break;
  56. end
  57. else
  58. if eq=true then
  59. begin
  60. write(output,(n div i));
  61. break;
  62. end;
  63. end;
  64. end.
Add Comment
Please, Sign In to add comment