Pagini recente » Monitorul de evaluare | Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #3300043) | Cod sursa (job #3356127)
#include <fstream>
#include <set>
#include <cmath> ///pentru abs()
///Varianta 3
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++) ///Punctele P[i] si P[j] formeaza o diagonala
{
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;
}