Pagini recente » Cod sursa (job #3162264) | Cod sursa (job #692727) | Cod sursa (job #1403950) | Cod sursa (job #692006) | Cod sursa (job #1788884)
#include <cstdio>
#include <queue>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct thing{
double x,y;
}v[1005];
int compara (double a,double b)
{
if (fabs (a-b)<=0.0001){
return 1;
}
return 0;
}
bool comp(thing a, thing b){
if(compara(a.x, b.x)){
return a.y - b.y < 0.0001;
}
return a.x - b.x < 0.0001;
}
bool binarySearch(int lf, int rg, double x, double y){
int i,step;
thing t;
t.x = x;
t.y = y;
for(step = 1;step <= rg;step <<= 1);
for(i = lf-1;step;step >>= 1){
if(i + step <= rg && comp(v[i+step], t)){
i += step;
}
}
if(compara(v[i].x, x) && compara(v[i].y, y)){
return 1;
}
return 0;
}
int main(){
freopen("patrate3.in", "r", stdin);
freopen("patrate3.out", "w", stdout);
int n,i,j;
double x,y;
scanf("%d", &n);
for(i = 1;i <= n;i++){
scanf("%lf %lf", &v[i].x, &v[i].y);
}
sort(v + 1, v + n + 1, comp);
bool ok = false;
int ans = 0;
for(i = 1;i <= n;i++){
for(j = i+1;j <= n;j++){
ok = true;
x = (v[i].x + v[j].x + v[i].y - v[j].y)/2.0;
y = (v[i].y + v[j].y + v[j].x - v[i].x)/2.0;
ok &= binarySearch(1, n, x, y);
x = (v[i].x + v[j].x + v[j].y - v[i].y)/2.0;
y = (v[i].y + v[j].y + v[i].x - v[j].x)/2.0;
ok &= binarySearch(1, n, x, y);
if(ok){
ans++;
}
}
}
printf("%d", ans/2);
return 0;
}