Pagini recente » Cod sursa (job #2211293) | Cod sursa (job #1921894) | Cod sursa (job #2489410) | Cod sursa (job #767097) | Cod sursa (job #1487668)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define e 0.0001
#define sinA 0.86603502540
#define cosA 0.500000000
#define maxN 1502
using namespace std;
int n, i, j, sol;
struct point
{
double x;
double y;
}v[maxN];
int cmp(const point a, const point b)
{
if (abs(a.x - b.x) < e)
return a.y < b.y;
return a.x < b.x;
}
void read()
{
freopen("triang.in", "r", stdin);
scanf("%d", &n);
for (i = 1; i <= n; ++ i)
scanf("%lf %lf", &v[i].x, &v[i].y);
}
int bs(point a)
{
int i = 1, p = 1 << 10;
while (p)
{
if (i + p <= n && (v[i + p].x <= a.x || abs(v[i + p].x - a.x) < e))
i += p;
p /= 2;
}
if (abs(v[i].x - a.x) > e)
return 0;
p = 1 << 10;
while (p)
{
if (i + p <= n && abs(v[i + p].x - v[i].x) < e && (v[i + p].y <= a.y || abs(v[i + p].y - a.y) < e))
i += p;
p /= 2;
}
return abs(v[i].y - a.y) < e;
}
void solve()
{
point p;
double x, y;
sort(v + 1, v + n + 1, cmp);
for (i = 1; i <= n; ++ i)
for (j = i + 1; j <= n; ++ j)
{
x = v[j].x - v[i].x;
y = v[j].y - v[i].y;
p.x = (x * cosA - y * sinA) + v[i].x;
p.y = (x * sinA + y * cosA) + v[i].y;
sol += bs(p);
p.x = (- x * cosA + y * sinA) + v[i].x;
p.y = (- x * sinA - y * cosA) + v[i].y;
sol += bs(p);
}
}
void write()
{
freopen("triang.out", "w", stdout);
printf("%d\n", sol / 3);
}
int main()
{
read();
solve();
write();
}