Pagini recente » Cod sursa (job #197271) | Cod sursa (job #195529) | Cod sursa (job #620547) | Cod sursa (job #1381370) | Cod sursa (job #1303477)
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
using namespace std;
#define maxn 10001
#define mod 666013
int n, answer=0;
vector<int> h[mod];
double err=1/10000;
struct point
{
double x, y;
};
point p[maxn];
int get_hash(point m)
{
int ans;
ans=floor((m.x*m.y));
if (ans<0) ans=-ans;
ans=ans%mod;
return ans;
}
bool finder(point m)
{
int hh=get_hash(m), i;
int a, b, c, d;
c=(int)(m.x);
d=(int)(m.y);
for (i=0;i<h[hh].size();i++)
{
a=(int)(p[h[hh][i]].x);
b=(int)(p[h[hh][i]].y);
if (a==c && b==d) return true;
}
return false;
}
int main()
{
ifstream f("patrate3.in");
ofstream g("patrate3.out");
int i, j;
point c, d, m;
double a, b;
f>>n;
for (i=0;i<n;i++)
{
f>>p[i].x>>p[i].y;
h[get_hash(p[i])].push_back(i);
}
for (i=0;i<n-1;i++)
for (j=i+1;j<n;j++)
{
m.x=(p[i].x+p[j].x)/2;
m.y=(p[i].y+p[j].y)/2;
c.x=-(p[i].y-m.y)+m.x;
c.y=(p[i].x-m.x)+m.y;
d.x=(p[i].y-m.y)+m.x;
d.y=-(p[i].x-m.x)+m.y;
if (finder(c) && finder(d)) answer++;
}
answer=answer/2;
g<<answer<<'\n';
}