Pagini recente » Cod sursa (job #2542053) | Cod sursa (job #1547052) | Cod sursa (job #1722212) | Cod sursa (job #1202390) | Cod sursa (job #2654558)
#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;
}