Pagini recente » Monitorul de evaluare | Istoria paginii runda/fminostress | Istoria paginii runda/testround/clasament | Istoria paginii runda/maricei2 | Cod sursa (job #1777576)
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#define base 666013
#define pii pair <int, int>
#define f first
#define s second
using namespace std;
vector <int> has[base];
pii v[1024];
inline int mod (int val)
{
val %= base;
val += base;
val %= base;
return val;
}
inline bool fin (pii x)
{
pii y = x;
y.f *= base;
y.f += y.s;
int ind = mod (y.f);
for (auto &it : has[ind])
if (v[it] == x) return true;
return false;
}
inline int aprox (double val)
{
int x = floor (val);
int y = ceil (val);
double xx = 1.0 * x;
double yy = 1.0 * y;
if (val - xx < yy - val) return x;
return y;
}
int main ()
{
freopen ("patrate3.in", "r", stdin);
freopen ("patrate3.out", "w", stdout);
int n;
scanf ("%d", &n);
for (int i = 1; i <= n; ++i)
{
double xx, yy;
scanf ("%lf %lf", &xx, &yy);
xx *= 10000.0;
yy *= 10000.0;
int x = aprox(xx);
int y = aprox(yy);
v[i] = pii (x, y);
x *= base;
x += y;
has[mod(x)].push_back (i);
}
int rez = 0;
for (int i = 1; i <= n; ++i)
for (int j = i + 1; j <= n; ++j)
{
int m1 = (v[i].f + v[j].f) >> 1;
int m2 = (v[i].s + v[j].s) >> 1;
if ((v[i].f + v[j].f) % 2 || (v[i].s + v[j].s) % 2) continue;
int d1 = m1 - v[i].f;
int d2 = m2 - v[i].s;
pii x = {m1 - d2, m2 + d1};
pii y = {m1 + d2, m2 - d1};
if (fin (x) && fin (y)) ++rez;
}
printf ("%d\n", rez >> 1);
return 0;
}