Pagini recente » Cod sursa (job #1930943) | Cod sursa (job #3041229) | Cod sursa (job #462785) | Cod sursa (job #1389128) | Cod sursa (job #71168)
Cod sursa(job #71168)
#include <cstdio>
#include <algorithm>
#include <cmath>
#define maxn 1500
#define eps 0.001
FILE *in = fopen("triang.in","r"), *out = fopen("triang.out","w");
int n;
int cnt;
struct pct
{
double x, y;
};
pct a[maxn];
bool operator<(const pct &t, const pct &d)
{
return d.x - t.x >= eps;
}
void read()
{
fscanf(in, "%d", &n);
for ( int i = 0; i < n; ++i )
fscanf(in, "%lf %lf", &a[i].x, &a[i].y);
}
int main()
{
read();
std::sort(a, a+n);
for ( int i = 0; i < n; ++i )
for ( int j = i + 1; j < n; ++j )
for ( int k = j + 1; k < n; ++k )
{
if ( fabs( (a[k].x - a[j].x) - (a[j].x - a[i].x) ) <= eps )
if ( fabs ( sqrt((a[k].x - a[j].x)*(a[k].x - a[j].x) + (a[k].y - a[j].y)*(a[k].y - a[j].y))
- ( a[k].x - a[i].x ) ) <= eps)
++cnt;
}
fprintf(out, "%d\n", cnt);
return 0;
}