Pagini recente » Cod sursa (job #3161539) | Cod sursa (job #2486726) | Cod sursa (job #1461661) | Cod sursa (job #2429844) | Cod sursa (job #1166927)
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
const int N=1005, MOD=666013;
struct pc{
int x, y;
bool operator==(const pc &e) const
{
return (x==e.x&&y==e.y);
}
pc(){}
pc(const int _x, const int _y)
{
x=_x;
y=_y;
}
};
class Hash{
public:
Hash(){}
bool find(const pc a)
{
int p=(10LL*a.x+a.y)%MOD;
for(vector<pc>::iterator it=H[p].begin();it!=H[p].end();it++) if(*it==a) return true;
return false;
}
void insert(const pc a)
{
if(find(a)) return;
int p=(10LL*a.x+a.y)%MOD;
H[p].push_back(a);
}
private:
vector<pc> H[MOD];
};
pc a[N];
Hash H;
int main()
{
freopen("patrate3.in", "r", stdin);
freopen("patrate3.out", "w", stdout);
int n, i, j, x, y, sol=0;
pc mij, x1, y1;
scanf("%d", &n);
for(i=1;i<=n;i++)
{
scanf("%d.%d", &x, &y);
if(x>=0) a[i].x=x*100000+y*10;
else a[i].x=x*100000-y*10;
scanf("%d.%d", &x, &y);
if(x>=0) a[i].y=x*100000+y*10;
else a[i].y=x*100000+y*10;
H.insert(a[i]);
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
mij=pc((a[i].x+a[j].x)/2, (a[i].y+a[j].y)/2);
x1=pc(mij.x-(a[i].y-mij.y), mij.y+(a[i].x-mij.x));
y1=pc(mij.x-(a[j].y-mij.y), mij.y+(a[j].x-mij.x));
if(H.find(x1)&&H.find(y1)) sol++;
}
}
printf("%d\n", sol/2);
}