SHARE
TWEET

Untitled

a guest Jun 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2. #include <cmath>
  3. #include <vector>
  4. #include <map>
  5. using namespace std;
  6.  
  7. #define X first
  8. #define Y second
  9.  
  10. int main() {
  11.     freopen("1.txt", "r", stdin);
  12.     int n,r=0;
  13.     scanf("%d", &n);
  14.     vector<pair<int,int> > a(n);
  15.     for(int i=0; i<n; i++)
  16.         scanf("%d%d", &a[i].X, &a[i].Y);
  17.  
  18.     double k;
  19.     map<double, int>::iterator it;
  20.     for(int i=0; i<n; i++) {
  21.         map<double, int> m;
  22.         for(int j=0; j<i; j++) {
  23.             if(a[i].Y == a[j].Y) k = 0.; else
  24.             if(a[i].X == a[j].X) k = ~(1<<31); else
  25.             k = (double)(a[j].Y-a[i].Y)/(double)(a[j].X-a[i].X);
  26.             m[k]++;
  27.         }
  28.         for(it = m.begin(); it!=m.end(); it++)
  29.             r += (it->second+1)*max(it->second-1,0);
  30.     }
  31.     printf("%d\n", r);
  32.     return 0;
  33. }
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top