Pagini recente » Cod sursa (job #2535947) | Cod sursa (job #2428907) | Cod sursa (job #1260338) | Cod sursa (job #2535896) | Cod sursa (job #2225405)
#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 < long double, long double > Punct;
int n,cnt;
Punct A[Dim];
vector < Punct > H[mod];
bool Egal(Punct X, Punct Y);
void Insert(Punct X);
bool Find(Punct 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;
}
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;
return 0;
}
void Insert(Punct X){
int i = (int)X.x % mod;
if ( i < 0)
i += mod;
H[i].push_back(X);
}
bool Egal(Punct X, Punct Y) {
return abs(X.x - Y.x) < eps and abs(X.y - Y.y) < eps;
}