Pagini recente » Cod sursa (job #2905297) | Cod sursa (job #852405) | Cod sursa (job #579001) | Cod sursa (job #2677022) | Cod sursa (job #2652020)
#include <fstream>
#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 A < *this ;
}
};
int N;
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, nrTr = 0;
Punct A, M;
f >> N;
for(i = 1; i <= N; i++)
{
f >> A.x >> A.y;
for(auto &B : S)
{
M = rotire(A, B);
if(S.find(M) != S.end())
nrTr++;
}
S.insert(A);
}
g << nrTr;
return 0;
}