Pagini recente » Cod sursa (job #1173717) | Cod sursa (job #2137554) | Cod sursa (job #188584) | Cod sursa (job #105691) | Cod sursa (job #3331570)
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
const int NMAX = 1000;
int n, answer;
ll x[NMAX + 1], y[NMAX + 1];
map<pair<ll, ll>, int> mp;
ll get_slope(ll x1, ll y1, ll x2, ll y2) {
return (y2 - y1) / (x2 - x1);
}
ll get_distance(ll x1, ll y1, ll x2, ll y2) {
return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}
int main()
{
fin >> n;
for(int i = 1; i <= n; i++) {
ld xx, yy;
fin >> xx >> yy;
x[i] = round(xx * 10000);
y[i] = round(yy * 10000);
}
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n; j++) {
ll slope = get_slope(x[i], y[i], x[j], y[j]);
ll dist = get_distance(x[i], y[i], x[j], y[j]);
mp[{slope, dist}]++;
}
}
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n; j++) {
ll slope = get_slope(x[i], y[i], x[j], y[j]);
ll dist = get_distance(x[i], y[i], x[j], y[j]);
answer += (mp[{slope, dist}] - 1);
}
}
fout << answer / 4 << '\n';
return 0;
}