Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. ifstream in("input.txt");
  8. ofstream out("output.txt");
  9.  
  10. struct point {
  11.     int x, y;
  12.     void print();
  13. };
  14. void point::print() {
  15.     out << x << " " << y << " " << endl;
  16. }
  17. double len(point a, point b) {
  18.     return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
  19. }
  20.  
  21.  
  22. int main() {
  23.     point circle, a[100];
  24.     double r;
  25.     cin >> r;
  26.     int n = 0;
  27.     while (in.peek() != EOF) {
  28.         int x,y;
  29.         in >> x >> y;
  30.         a[n].x = x;
  31.         a[n].y = y;
  32.         n++;
  33.     }
  34.     n--;
  35.     point ans;
  36.     int k = INT_MIN;
  37.     for (int i = 0; i < n; i++) {
  38.          circle.x = a[i].x;
  39.          circle.y = a[i].y;
  40.          int cnt = 0;
  41.          for (int j = 0; j < n; j++) {
  42.               if (len(circle,a[j]) <= r) {
  43.                    cnt++;
  44.               }
  45.          }
  46.          if (cnt > k) {
  47.               ans.x = circle.x;
  48.               ans.y = circle.y;
  49.               k = cnt;
  50.          }
  51.     }
  52.     ans.print();
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement