Pagini recente » Cod sursa (job #3357667) | Cod sursa (job #3361379) | Cod sursa (job #2644265) | Monitorul de evaluare | Cod sursa (job #3361503)
#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e3, INM = 1e6, INM2 = 1e6, MOD = 1e9 + 7;
const long long int BINM = 1e10, INF = 1e18 + 67, ADD = 1e10 + 123;
ifstream fin ("patrate3.in");
ofstream fout ("patrate3.out");
struct coords {
long long int x, y;
bool operator<(const coords& other) const {
if (x != other.x)
return x < other.x;
return y < other.y;
}
};
unordered_set<int> mp;
coords puncte[LIM + 9];
int main() {
int n;
fin >> n;
for (int i = 1; i <= n; i++) {
string nr;
char ch;
fin >> nr;
int p = 0;
for (int i = 0; i < nr.size(); i++) {
if (nr[i] == '.')
p = i;
}
string newnr{};
for (int i = 0; i < p; i++) {
newnr += nr[i];
}
for (int i = p + 1; i < nr.size(); i++) {
newnr += nr[i];
}
long long int x = atoi(newnr.c_str()) * 10ll;
fin >> nr;
p = 0;
for (int i = 0; i < nr.size(); i++) {
if (nr[i] == '.')
p = i;
}
newnr = "";
for (int i = 0; i < p; i++) {
newnr += nr[i];
}
for (int i = p + 1; i < nr.size(); i++) {
newnr += nr[i];
}
long long int y = atoi(newnr.c_str()) * 10ll;
puncte[i] = {x, y};
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
long long int dx, dy, mx, my;
dx = abs(puncte[i].x - puncte[j].x);
dy = abs(puncte[i].y - puncte[j].y);
long long int xs = puncte[i].x < puncte[j].x ? puncte[i].x : puncte[j].x;
long long int ys = puncte[i].y < puncte[j].y ? puncte[i].y : puncte[j].y;
mx = dx / 2 + xs;
my = dy / 2 + ys;
//cout << s.second.first << ' ' << s.second.second << ' ' << s.len;
int hash = 1ll * dx % MOD;
hash = 1ll * hash * dy % MOD * ADD % MOD;
hash = 1ll * hash * mx % MOD * ADD % MOD;
hash = 1ll * hash * my % MOD * ADD % MOD;
if (mp.count(hash)) {
ans++;
}
mp.insert(hash);
}
}
fout << ans;
return 0;
}