Pagini recente » Rating Cosmin (birligeacosmin) | Cod sursa (job #2420772) | Cod sursa (job #1691037) | Cod sursa (job #1156359) | Cod sursa (job #2837227)
//#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#define ll long long
using namespace std;
struct panta
{
int sus, jos;
};
struct pct
{
int x, y;
};
bool cmp(panta a, panta b)
{
return a.sus * b.jos < a.jos * b.sus;
}
bool egal(panta a, panta b)
{
return a.sus * b.jos == a.jos * b.sus;
}
vector <panta> v;
const int NMAX = 1003;
pct a[NMAX];
int main()
{
ifstream cin("trapez.in");
ofstream cout("trapez.out");
int n, i, j;
cin >> n;
for (i = 1; i <= n; i++)
cin >> a[i].x >> a[i].y;
for (i = 1; i + 1 <= n; i++)
for (j = i + 1; j <= n; j++)
{
panta aux;
aux.sus = a[j].y - a[i].y;
aux.jos = a[j].x - a[i].x;
v.push_back(aux);
}
sort(v.begin(), v.end(), cmp);
int first = 0, cnt = 1;
long long ans = 0;
for (i = 1; i < v.size(); i++)
if (egal(v[first], v[i]))
cnt++;
else
{
ans += 1LL * cnt * (cnt - 1) / 2;
first = i;
cnt = 1;
}
ans += cnt * (cnt - 1) / 2;
cout << ans;
}