Pagini recente » Cod sursa (job #2343548) | Cod sursa (job #667224) | Cod sursa (job #2445988) | Cod sursa (job #2499111) | Cod sursa (job #2607449)
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
a = abs(a), b = abs(b);
while (a)
swap(a, b %= a);
return b;
}
int main()
{
ifstream in("trapez.in");
ofstream out("trapez.out");
int n;
in >> n;
vector <pair <int, int>> coord(n);
for (auto & i : coord)
in >> i.first >> i.second;
map <pair <int, int>, int> dif;
long long ans = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
int dx = coord[j].first - coord[i].first;
int dy = coord[j].second - coord[i].second;
int g = gcd(dx, dy);
dx /= g, dy /= g;
if (dx < 0)
dx = -dx, dy = -dy;
ans += dif[{ dx, dy }];
dif[{ dx, dy }]++;
}
}
out << ans << '\n';
return 0;
}