Pagini recente » Cod sursa (job #717031) | Cod sursa (job #59970) | Cod sursa (job #1605404) | Cod sursa (job #376381) | Cod sursa (job #2789634)
#include <bits/stdc++.h>
#define PI 3.14159265
#define sin1 sin(PI / 3)
#define cos1 cos(PI / 3)
#define sin2 sin(-PI / 3)
#define cos2 cos(-PI / 3)
#define eps 0.0001
#define cons 10000000
using namespace std;
struct pct
{
double x, y;
} v[1501];
map<int, map<int, bool>> f;
bool cmp(pct a, pct b)
{
if (a.x - b.x < eps && a.x - b.x >= 0)
return a.y - b.y < 0;
return a.x - b.x < 0;
}
int main()
{
ifstream cin("triang.in");
ofstream cout("triang.out");
int n, i, j, cnt = 0;
cin >> n;
for (i = 0; i < n; i++)
{
cin >> v[i].x >> v[i].y;
f[v[i].x * cons][v[i].y * cons] = 1;
}
sort(v, v + n, cmp);
for (i = 0; i < n; i++)
{
for (j = i + 1; j < n; j++)
{
double x1, x2, y1, y2, xx, yy;
x1 = v[i].x, x2 = v[j].x, y1 = v[i].y, y2 = v[j].y;
y2 -= y1, x2 -= x1;
xx = x2 * cos1 - y2 * sin1;
yy = x2 * sin1 + y2 * cos1;
y1 += yy, x1 += xx;
if (f[x1 * cons][y1 * cons] == 1)
cnt++;
x1 = v[i].x, x2 = v[j].x, y1 = v[i].y, y2 = v[j].y;
y2 -= y1, x2 -= x1;
xx = x2 * cos2 - y2 * sin2;
yy = x2 * sin2 + y2 * cos2;
y1 += yy, x1 += xx;
if (f[x1 * cons][y1 * cons] == 1)
cnt++;
}
}
cout << cnt;
}