Pagini recente » Cod sursa (job #939480) | Cod sursa (job #2374873) | Cod sursa (job #1506304) | Cod sursa (job #3259173) | Cod sursa (job #3235729)
#include <fstream>
#include <cmath>
#include <set>
using namespace std;
const double EPS = 1e-5;
struct Punct
{
double x, y;
Punct(double x = 0.0, double y = 0.0): x(x), y(y) {}
bool operator<(const Punct &A)const
{
if(abs(x - A.x) > EPS)
return x < A.x;
if(abs(y - A.y) > EPS)
return y < A.y;
return 0;
}
};
int n;
Punct P[1001];
set<Punct>S;
ifstream f("patrate3.in");
ofstream g("patrate3.out");
void solve()
{
Punct M, A, B;
int nrp = 0;
for(int i = 1; i < n; i++)
for(int j = i + 1; j <= n; j++)
{
M.x = (P[i].x + P[j].x) / 2;
M.y = (P[i].y + P[j].y) / 2;
A.x = M.x - P[j].y + M.y;
A.y = M.y + P[j].x - M.x;
B.x = M.x + P[j].y - M.y;
B.y = M.y - P[j].x + M.x;
if(S.find(A)!=S.end()&&S.find(B)!=S.end())
nrp++;
}
g << nrp / 2;
}
int main()
{
f >> n;
for(int i = 1; i <= n; i++)
{
f >> P[i].x >> P[i].y;
S.insert(P[i]);
}
solve();
f.close();
g.close();
return 0;
}