Pagini recente » Cod sursa (job #2261630) | Cod sursa (job #2094678) | Cod sursa (job #1278853) | Cod sursa (job #3231567) | Cod sursa (job #913876)
Cod sursa(job #913876)
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
struct POINT {
double x, y;
};
bool cmp(POINT a, POINT b) {
if(a.x < b.x)
return 1;
if(a.x == b.x)
return a.y < b.y;
return 0;
}
long N, nrpat;
vector<POINT> v;
int main() {
long i, j;
POINT tmp, tmp2, tmp3;
double x, y;
bool one;
vector<POINT>::iterator it;
freopen("patrate3.in", "r", stdin);
freopen("patrate3.out", "w", stdout);
scanf("%ld", &N);
for(i = 1; i <= N; i++) {
scanf("%lf %lf", &x, &y);
tmp.x = x;
tmp.y = y;
v.push_back(tmp);
}
sort(v.begin(), v.end(), cmp);
for(i = 0; i < N; i++)
for(j = i + 1; j < N; j++) {
x = fabs(v[j].x - v[i].x);
y = fabs(v[j].y - v[i].y);
tmp.x = v[i].x + y;
tmp.y = v[i].y + x;
tmp2.x = tmp.y - y;
tmp2.y = tmp.x - x;
it = lower_bound(v.begin(), v.end(), tmp, cmp);
if((*it).x == tmp.x && (*it).y == tmp.y)
one = true;
it = lower_bound(v.begin(), v.end(), tmp2, cmp);
if(one && (*it).x == tmp2.x && (*it).y == tmp2.y)
nrpat++;
}
printf("%ld", nrpat / 2);
return 0;
}