Pagini recente » Cod sursa (job #1182733) | Cod sursa (job #275579) | Cod sursa (job #1449692) | Cod sursa (job #2776964) | Cod sursa (job #2980925)
#include <fstream>
#include <algorithm>
#include <map>
using namespace std;
ifstream cin ("trapez.in");
ofstream cout ("trapez.out");
const int INF = 2e9 + 1;
const int N = 1e3;
class varza
{
public:
int x, y;
friend istream& operator >> (istream &is, varza &a)
{
is >> a.x >> a.y;
return is;
}
bool operator < (const varza &a)const
{
if (a.x != x)
return x < a.x;
return y < a.y;
}
} a[N + 1];
int n, res, m;
class lil
{
public:
int x, y;
bool operator < (const lil &a)const
{
return y * a.x < x * a.y;
}
bool operator == (const lil &a)const
{
return (a.x * y == a.y * x);
}
} v[N * N + 1];
int main()
{
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
sort (a + 1, a + n + 1);
for (int i = 1; i <= n; ++i)
for (int j = i + 1; j <= n; ++j)
v[++m].y = a[j].y - a[i].y, v[m].x = a[j].x - a[i].x;
sort (v + 1, v + m + 1);
int nr = 1;
v[m + 1].x = v[m + 1].y = -INF;
for (int i = 2; i <= m + 1; ++i)
{
if (v[i] == v[i - 1])
++nr;
else
{
res = res + (nr - 1) * nr / 2;
nr = 1;
}
}
cout << res << '\n';
return 0;
}