Pagini recente » Cod sursa (job #3215810) | Cod sursa (job #3287205) | Cod sursa (job #2435507) | Cod sursa (job #3290810) | Cod sursa (job #2752180)
#include <cmath>
#define x first
#define y second
#include <fstream>
#include <vector>
#define eps 0.00000001
using namespace std;
ifstream fin ("patrate3.in");
ofstream fout ("patrate3.out");
const int Dim = 1001,mod = 636013;
typedef pair < double, double > Punct;
int n,cnt;
Punct A[Dim];
vector < Punct > H[mod];
bool Egal(Punct X, Punct Y)
{
return fabs(X.x - Y.x) <= eps and fabs(X.y - Y.y) <= eps;
}
bool Find(Punct X)
{
int i = (int)X.x % mod;
if ( i < 0)
i += mod;
for ( const auto & j : H[i])
if ( Egal(j,X) )
return 1;
i = (int)(X.x+1) % mod;
if ( i < 0)
i += mod;
for ( const auto & j : H[i])
if ( Egal(j,X) )
return 1;
i = (int)(X.x-1) % mod;
if ( i < 0)
i += mod;
for ( const auto & j : H[i])
if ( Egal(j,X) )
return 1;
return 0;
}
void Insert(Punct X)
{
int i = (int)X.x % mod;
if ( i < 0)
i += mod;
H[i].push_back(X);
}
int main()
{
fin >> n;
for ( int i = 1; i <= n; ++i)
{
fin >> A[i].x >> A[i].y;
Insert(A[i]);
}
for ( int i = 1; i <= n; ++i)
for ( int j = i + 1; j <= n; ++j)
{
Punct Mid,X,Y;
Mid = {(A[i].x + A[j].x) / 2, (A[i].y + A[j].y) / 2};
X = {Mid.x - (A[j].y - Mid.y), Mid.y + (A[j].x - Mid.x)};
Y = {Mid.x + (A[j].y - Mid.y), Mid.y - (A[j].x - Mid.x)};
if ( Find(X)and Find(Y))
++cnt;
}
fout << cnt/2;
}