Pagini recente » Cod sursa (job #3357370) | Cod sursa (job #1397408) | Cod sursa (job #1934476) | Cod sursa (job #960881) | Cod sursa (job #3309322)
#include <fstream>
#include <set>
#include <cmath>
using namespace std;
const double EPS = 1e-3;
const int NMAX = 1501;
int n, cnt;
struct punct
{
double x, y;
bool operator<(const punct &B)const
{
if(abs(x - B.x) > EPS)
return x < B.x;
//
if(abs(y - B.y) > EPS)
return y < B.y;
return 0;
}
} pc[NMAX];
set<punct> S;
ifstream f("triang.in");
ofstream g("triang.out");
punct rotatie(const punct &a, const punct &b)
{
punct c;
double sin = sqrt(3) / 2, cos = 1.0 / 2;
c.x = a.x + (b.x - a.x) * cos - (b.y - a.y) * sin;
c.y = a.y + (b.x - a.x) * sin + (b.y - a.y) * cos;
return c;
}
int main()
{
f >> n;
for(int i = 1; i <= n; i++)
{
f >> pc[i].x >> pc[i].y;
for(int j = 1; j < n; j++)
if(S.find(rotatie(pc[i], pc[j])) != S.end())
cnt++;
S.insert(pc[i]);
}
g << cnt;
f.close();
g.close();
return 0;
}