Pagini recente » Cod sursa (job #49067) | Cod sursa (job #2055110) | Cod sursa (job #1237748) | Cod sursa (job #1636679) | Cod sursa (job #2455718)
#include <cstdio>
#include <map>
using namespace std;
pair<int, int>p[1005];
pair<int, int>pa;
int n, s;
/**struct panta
{
int numarator, numitor;
}pa;**/
map<pair<int, int>, int> fr;
int cmmdc(int x, int y)
{
if(y==0)
return x;
cmmdc(y, x%y);
}
int rez(int n)
{
return n*(n-1)/2;
}
int main()
{
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
scanf("%d", &n);
for(int i=1;i<=n;i++)
{
int x, y;
scanf("%d %d", &p[i].first, &p[i].second);
//int diviz=cmmdc(x, y);
//pa.numarator=x/diviz;
//pa.numitor=y/diviz;
//fr[{x, y}]++;
}
for(int i=1;i<n;i++)
for(int j=i+1;j<=n;j++)
{
pa.first=p[j].second-p[i].second;
pa.second=p[j].first-p[i].first;
int diviz=cmmdc(pa.first, pa.second);
pa.first/=diviz;
pa.second/=diviz;
//printf("%d %d\n", pa.first, pa.second);
fr[{pa.first, pa.second}]++;
}
for(auto i:fr)
{
s+=rez(i.second);
}
printf("%d", s);
return 0;
}