artemgf

Охота на зайцев

Dec 3rd, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.82 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5. #include <set>
  6. #include <algorithm>
  7. #include <vector>
  8. #include <stdio.h>
  9. #include <cmath>
  10. #include <math.h>
  11. #include <queue>
  12. #include <stack>
  13. #include <climits>
  14. #include <deque>
  15. #include <ctime>
  16.  
  17. using namespace std;
  18.  
  19. typedef long long ll;
  20. typedef unsigned long long ull;
  21. typedef unsigned int ui;
  22.  
  23. #define mh() make_heap()
  24. #define poph() pop_heap()
  25. #define pushh() push_heap()
  26. #define sor(n) n.begin(), n.end()
  27. #define mp make_pair
  28. #define files freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
  29. #define p(T) pair<T,T>
  30.  
  31. #define formx(a1,b1,c1,a2,b2,c2) ((a1*c2-a2*c1)/(a1*b2-b1*a2))
  32. #define formy(a1,b1,c1,a2,b2,c2) ((c1*b2-c2*b1)/(a1*b2-b1*a2))
  33. #define forma(y1,y2) (y2-y1)
  34. #define formb(x1,x2) (x1-x2)
  35. #define formc(x1,y1,x2,y2) (x1*(y2-y1)-y1*(x2-x1))
  36. #define ras(x1,y1,x2,y2) sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
  37.  
  38. struct cord
  39. {
  40.     double x1, y1, x2, y2;
  41. };
  42. struct limcord
  43. {
  44.     double x, y;
  45.     bool good;
  46. };
  47.  
  48. bool checkparal(double a1, double a2, double b1, double b2)
  49. {
  50.     return a1 / b1 == a2 / b2;
  51. }
  52.  
  53. limcord findt(cord c, cord now)
  54. {
  55.     double a1 = forma(now.y1, now.y2);
  56.     double b1 = formb(now.x1, now.x2);
  57.     double c1 = formc(now.x1, now.y1, now.x2, now.y2);
  58.     double a2 = forma(c.y1, c.y2);
  59.     double b2 = formb(c.x1, c.x2);
  60.     double c2 = formc(c.x1, c.y1, c.x2, c.y2);
  61.  
  62.     if (!checkparal(a1, a2, b1, b2))
  63.     {
  64.         double x = formx(a1, b1, c1, a2, b2, c2);
  65.         double y = formy(a1, b1, c1, a2, b2, c2);
  66.         return{ x,y, true };
  67.     }
  68.     else
  69.     {
  70.         return{ NULL,NULL, false };
  71.     }
  72. }
  73.  
  74. bool checkT(limcord now, cord ot)
  75. {
  76.     if (ras(ot.x1, ot.y1, ot.x2, ot.y2) == ras(ot.x1, ot.y1, now.x, now.y) + ras(ot.x2, ot.y2, now.x, now.y))
  77.         return true;
  78.     else
  79.         return false;
  80. }
  81.  
  82. vector <ll> fib;
  83. void aadfib()
  84. {
  85.     fib.push_back(1);
  86.     fib.push_back(1);
  87.     for (int i = 3; i <= 1e7; i++)
  88.     {
  89.         fib.push_back(fib[i - 1] + fib[i - 2]);
  90.     }
  91. }
  92.  
  93. #define formk(x1,x2,y1,y2) (y1 - y2) / (x1 - x2)
  94. #define formbk(k,x2,y2) y2 - k * x2
  95.  
  96. int gcd(int a, int b)
  97. {
  98.     while (b)
  99.     {
  100.         a %= b;
  101.         swap(a, b);
  102.     }
  103.     return a;
  104. }
  105. int main()
  106. {
  107.     files;
  108.     map <p(double), int>cordm;
  109.     ll n;
  110.     int  x, y;
  111.     cin >> n;
  112.     vector <p(int)>cords;
  113.     for (int i = 1; i <= n; i++)
  114.     {
  115.         cin >> x >> y;
  116.         cords.push_back(mp(x, y));
  117.     }
  118.     int ms = 0;
  119.     int  maxs;
  120.     for (int i = 0; i < n; i++)
  121.     {
  122.         x = 0;
  123.         maxs = 0;
  124.         for (int j = i+1; j < n; j++)
  125.         {
  126.             if (cords[i].first == cords[j].first)
  127.             {
  128.                 x++;
  129.             }
  130.             else
  131.             {
  132.                 int k = cords[j].second - cords[i].second;
  133.                 int b = cords[j].first - cords[i].first;
  134.                 int g = gcd(k, b);
  135.                 b /= g;
  136.                 k /= g;
  137.                 cordm[mp(k, b)]++;
  138.                 maxs = max(maxs,cordm[mp(k, b)]);
  139.             }
  140.             maxs = max(maxs, x);
  141.         }
  142.         ms = max(maxs + 1, ms);
  143.         cordm.clear();
  144.     }
  145.     cout << ms;
  146.     return 0;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment