Pagini recente » Cod sursa (job #3361476) | Cod sursa (job #546813) | Cod sursa (job #1509384) | Cod sursa (job #3230419) | Cod sursa (job #3361497)
#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e3, INM = 1e6, INM2 = 1e6;
const long long int BINM = 1e10, INF = 1e18 + 67;
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;
}
};
set<pair<pair<int, int>, pair<int, 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++) {
pair<pair<int, int>, pair<int, int>> s;
s.first.first = abs(puncte[i].x - puncte[j].x);
s.first.second = 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;
s.second.first = s.first.first / 2 + xs;
s.second.second = s.first.second / 2 + ys;
//cout << s.second.first << ' ' << s.second.second << ' ' << s.len;
if (mp.count({{s.first.second, s.first.first}, s.second})) {
ans++;
}
mp.insert(s);
}
}
fout << ans;
return 0;
}