SHARE
TWEET

Untitled

a guest Oct 20th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define f first
  5. #define s second
  6.  
  7. using namespace std;
  8.  
  9. const int N = 2506;
  10.  
  11. ll n, tx, ans, k, k1, k2, st;
  12.  
  13. map < pair <int, int>, int > sto;
  14. map < pair <int, int>, int > :: iterator it;
  15.  
  16. pair <int, int> t, t1, t2, a[N];
  17.  
  18. int main()
  19. {
  20.     ios_base::sync_with_stdio(); cin.tie(); cout.tie();
  21.     cin >> n;
  22.     for (int i = 1; i <= n; i++)
  23.         cin >> a[i].f >> a[i].s;
  24.  
  25.     for (int i = 1; i <= n; i++)
  26.     {
  27.         sto.clear();
  28.         for (int j = 1; j <= n ;j++)
  29.         {
  30.             if (i == j)
  31.                 continue;
  32.             t = {a[j].f - a[i].f, a[j].s - a[i].s};
  33.             st = __gcd(t.f, t.s);
  34.             t.f /= st;
  35.             t.s /= st;
  36.             sto[t]++;
  37.         }
  38.  
  39.  
  40.         for (it = sto.begin(); it != sto.end(); it++)
  41.         {
  42.             t = (*it).f;
  43.             k = (*it).s;
  44.             if (k == 0)
  45.                 continue;
  46.             k1 = 0;
  47.             k2 = 0;
  48.  
  49.             t1 = {t.f, -t.s};
  50.             if (t1 != t)
  51.                 k1 = sto[t1];
  52.  
  53.             t2 = {-t.s, t.f};
  54.             if (t2 != t)
  55.                 k2 = sto[t2];
  56.  
  57.             ans += k * k1 + k * k2;
  58.         }
  59.     }
  60.  
  61.     cout << ans;
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top