Advertisement
Dennnhhhickk

Untitled

Nov 25th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. program Project2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. const
  9. MAXIN = 100000;
  10.  
  11. type
  12. point = record
  13. x, y: extended;
  14. end;
  15. vector = record
  16. x, y: extended;
  17. end;
  18.  
  19. var
  20. n, m, k, i, j, p, w1, ans: integer;
  21. a: array [0..MAXIN] of point;
  22. v, w: vector;
  23. r, x1, y1: extended;
  24.  
  25. function max(a, b: integer): integer;
  26. begin
  27. if (a > b) then
  28. max := a
  29. else
  30. max := b;
  31. end;
  32.  
  33. function make_vector(point1, point2: point): vector;
  34. begin
  35. make_vector.x := point2.x - point1.x;
  36. make_vector.y := point2.y - point1.y;
  37. end;
  38.  
  39. function cross_product(vector1, vector2: vector): extended;
  40. begin
  41. cross_product := vector1.x * vector2.y - vector2.x * vector1.y;
  42. end;
  43.  
  44. begin
  45. readln(a[0].x, a[0].y, r);
  46. readln(n);
  47. p := 0;
  48.  
  49. for i := 1 to n do
  50. begin
  51. read(x1, y1);
  52. if (sqrt(sqr(a[0].x - x1) + sqr(a[0].y - y1)) <= r) then
  53. begin
  54. inc(p);
  55. a[p].x := x1;
  56. a[p].y := y1;
  57. end;
  58. end;
  59.  
  60. for i := 1 to n do
  61. begin
  62. m := 0;
  63. k := 0;
  64. w := make_vector(a[0], a[i]);
  65. for j := 1 to n do
  66. if (i <> j) then
  67. begin
  68. v := make_vector(a[0], a[j]);
  69. if (cross_product(w, v) >= 0) then
  70. inc(k)
  71. else
  72. inc(m);
  73. end;
  74. ans := max(ans, max(m, k));
  75. end;
  76.  
  77. writeln(ans);
  78. readln;
  79. readln;
  80. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement