Pagini recente » Cod sursa (job #3240611) | Cod sursa (job #283689) | Cod sursa (job #42009) | Cod sursa (job #1877819) | Cod sursa (job #2648306)
#include <fstream>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
const double EPS = 1e-5;
struct Punct
{
double x, y;
bool operator == (const Punct& A) const
{
return abs(x - A.x) <= EPS && abs(y - A.y) <= EPS;
}
bool operator < (const Punct& A) const
{
if(abs(x - A.x) <= EPS)
return y + EPS <= A.y;
return x + EPS <= A.x;
}
bool operator > (const Punct& A) const
{
return *this < A;
}
};
int N;
Punct P[1501];
set<Punct> S;
ofstream g("triang.out");
ifstream f("triang.in");
Punct rotire(const Punct &A, const Punct &B)
{
static double c = 0.5, s = sqrt(3) / 2;
double dx = B.x - A.x, dy = B.y - A.y;
Punct C;
C.x = dx * c - dy * s + A.x;
C.y = dx * s + dy * c + A.y;
return C;
}
int main()
{
int i, j, nrTr = 0;
f >> N;
for(i = 1; i <= N; i++)
f >> P[i].x >> P[i].y;
//
sort(P + 1, P + N + 1);
//
Punct M;
for(i = 1; i <= N; i++)
{
for(j = 1; j < i; j++)
{
M = rotire(P[i], P[j]);
if(S.find(M) != S.end())
nrTr++;
}
S.insert(P[i]);
}
g << nrTr;
return 0;
}