Pagini recente » Cod sursa (job #358473) | Cod sursa (job #2774186) | Cod sursa (job #2371917) | Cod sursa (job #1097097) | Cod sursa (job #2313713)
#include <fstream>
#include <unordered_set>
using namespace std;
#define M 10000
struct coord {
long long x, y;
};
unordered_set <long long> c;
int main() {
FILE *in = fopen("patrate3.in", "r");
FILE *out = fopen("patrate3.out", "w");
int n, i, j;
long long z;
int x, y;
fscanf(in, "%d", &n);
coord v[n];
for(i = 0; i < n; i ++) {
fscanf(in, "%d.%d", &x, &y);
v[i].x = x * M + y;
fscanf(in, "%d.%d", &x, &y);
v[i].y = x * M + y;
z = v[i].x * M + v[i].y;
c.insert(z);
}
coord m, c1, c2;
int ct = 0;
for(i = 0; i < n; i ++) {
for(j = i + 1; j < n; j ++) {
m.x = (v[i].x + v[j].x) / 2;
m.y = (v[i].y + v[j].y) / 2;
c1.x = m.x + (v[i].y - v[j].y) / 2;
c1.y = m.y - (v[i].x - v[j].x) / 2;
z = c1.x * M + c1.y;
if(c.find(z) != c.end()) {
c2.x = m.x - (v[i].y - v[j].y) / 2;
c2.y = m.y + (v[i].x - v[j].x) / 2;
z = c2.x * M + c2.y;
if(c.find(z) != c.end()) {
//printf("%lld %lld %lld %lld %lld %lld %lld %lld\n", v[i].x, v[i].y, v[j].x, v[j].y, c1.x, c1.y, c2.x, c2.y);
ct ++;
}
}
}
z = v[i].x * M + v[i].y;
c.erase(c.find(z));
}
fprintf(out, "%d", ct);
return 0;
}