SHARE
TWEET

Untitled

a guest Oct 20th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int gcd (int a, int b) {
  2.     while (b) {
  3.         a %= b;
  4.         swap (a, b);
  5.     }
  6.     return a;
  7. }
  8.  
  9. signed main() {
  10. #ifdef DEBUG
  11.     fr("input.txt");
  12.     // fw("output.txt");
  13. #else
  14.     fr("input.txt");
  15.     fw("output.txt");
  16. #endif
  17.     int n;
  18.     cin >> n;
  19.     vector<pair<int, int> > pt(n);
  20.     int ans = 0;
  21.     for(int i = 0; i < n; i++) cin >> pt[i].f >> pt[i].s;
  22.     for(int i = 0; i < n; i++){
  23.         int d = 0;
  24.         map<pair<int, int>, int> kek;
  25.         for(int j = 0; j < n; j++){
  26.             if(i == j) continue;
  27.             int dx = pt[i].f - pt[j].f;
  28.             int dy = pt[i].s - pt[j].s;
  29.             int g = gcd(dx, dy);
  30.             if(g != 0){
  31.                 dx /= g;
  32.                 dy /= g;
  33.             }
  34.             kek[{dx, dy}]++;
  35.         }
  36.         for(auto &a: kek){
  37.             // cout << a.first.first << ' ' << a.first.second << ':' << a.second << endl;
  38.             d += a.second * kek[{a.first.second, -a.first.first}];
  39.             d += a.second * kek[{-a.first.second, a.first.first}];
  40.         }
  41.         ans += d / 2;
  42.         // cout << d << endl;
  43.     }
  44.     cout << ans;
  45.  
  46. }
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