Pagini recente » Cod sursa (job #1057200) | Clasament Junior Challenge 2016 | Cod sursa (job #1172376) | Clasament FMI No Stress 2012 | Cod sursa (job #2225409)
#include <cmath>
#define x first
#define y second
#include <fstream>
#include <vector>
using namespace std;
ifstream fin ("patrate3.in");
ofstream fout ("patrate3.out");
const int Dim = 1001,mod = 636013;
const double eps = 1e-8;
typedef pair < int, int > 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;
double x,y;
for ( int i = 1; i <= n; ++i) {
fin >> x >> y;
x *= 1000;
y *= 1000;
A[i] ={ x,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 = X.x % mod;
if ( i < 0)
i += mod;
for ( const auto & j : H[i])
if ( j == X )
return 1;
return 0;
}
void Insert(Punct X){
int i = X.x % mod;
if ( i < 0)
i += mod;
H[i].push_back(X);
}