Pagini recente » Cod sursa (job #2939252) | Cod sursa (job #1506185) | Cod sursa (job #2962188) | Cod sursa (job #1649907) | Cod sursa (job #601704)
Cod sursa(job #601704)
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define MAXN 1505
#define EPS 0.0001
double X[MAXN], Y[MAXN];
struct cmp {
bool operator()(const int &a, const int &b){
if(abs(X[a]-X[b]) < EPS)
return Y[a]<Y[b];
else
return X[a]<X[b];
}
};
inline double L(double x1, double y1, double x2, double y2){
return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}
int main(){
freopen("triang.in", "r", stdin);
freopen("triang.out", "w", stdout);
int N, i, j, k, I[MAXN], cnt;
static double D[MAXN][MAXN];
scanf("%d", &N);
for(i=1; i<=N; i++){
scanf("%lf%lf", X+i, Y+i);
I[i]=i;
}
sort(I+1, I+N+1, cmp());
for(i=1; i<=N; i++)
for(j=1; j<=N; j++)
D[i][j]=L(X[I[i]], Y[I[i]], X[I[j]], Y[I[j]]);
cnt=0;
for(i=1; i<=N; i++)
for(j=i+1; j<=N; j++)
for(k=j+1; k<=N; k++)
if(abs(D[i][j]-D[j][k])<EPS && abs(D[j][k]-D[k][i])<EPS)
cnt++;
printf("%d\n", cnt);
return 0;
}