Cod sursa(job #2550808)

Utilizator smoc_georgemarianSmoc George-Marian smoc_georgemarian Data 19 februarie 2020 10:05:45
Problema Trapez Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <bits/stdc++.h>
#define NMAX 1009
#define INF 99999
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
struct tip{double x; double y;};
struct tip1{double m; double lg;};
map<double, int>H;
map<tip1, int>H1;
map<double, int>::iterator it;
tip a[NMAX];
int n;
double m;
int i,j;
int main()
{fin>>n;
 for(i=1;i<=n;i++)
      fin>>a[i].x>>a[i].y;

 for(i=1;i<=n;i++)
     for(j=i+1;j<=n;j++)
        {
         if(a[i].x==a[j].x)
              {
                H[INF]++;
              }
         else
         {
        m= (a[j].y-a[i].y)/(a[j].x-a[i].x);

        H[m]++;
         }
        }
  int sum=0;
  for(it=H.begin();it!=H.end();it++)
      sum+= (*it).second * ( (*it).second  -1)/2;
  fout<<sum;
    return 0;
}