Pagini recente » Cod sursa (job #2765499) | Cod sursa (job #858512) | Cod sursa (job #1053521) | Cod sursa (job #2387736) | Cod sursa (job #2440056)
#include <bits/stdc++.h>
using namespace std;
ifstream f("triang.in");
ofstream g("triang.out");
const int NMAX = 1505;
vector < pair < double, double > > v;
int n;
struct mat{
double leng;
int id;
} dist[NMAX][NMAX];
double cdist[NMAX][NMAX];
int ans;
bool viz[NMAX][NMAX];
double pow(double X){
return X * X;
}
double distance(pair <double, double> X, pair <double, double> Y){
return sqrt(pow(X.first - Y.first) + pow(X.second - Y.second));
}
bool cmp(const mat &X, const mat &Y){
return X.leng < Y.leng;
}
double modul(double X){
return max(X, -X);
}
bool egal(double X, double Y){
return modul(X - Y) < 0.0001;
}
int main(){
int i,j,o;
f >> n;
v.resize(n);
for(i = 0 ; i < n ; i++)
f >> v[i].first >> v[i].second;
for(i = 0 ; i < n ; i++)
for(j = i + 1 ; j < n ; j++){
viz[i][j] = 1;
dist[i][j].leng = distance(v[i], v[j]);
cdist[i][j] = dist[i][j].leng;
dist[i][j].id = j;
}
for(i = 0 ; i < n ; i++)
sort(dist[i], dist[i] + n, cmp);
for(i = 0 ; i < n ; i++){
for(j = 0 ; j < n - 1; j++)
if(!egal(dist[i][j].leng, 0))
if(egal(dist[i][j].leng, dist[i][j + 1].leng)){
for(o = j + 1 ; egal(dist[i][j].leng, dist[i][o].leng) ; o++)
if(egal(dist[i][j].leng, dist[i][o].leng))
if(egal(cdist[dist[i][o].id][dist[i][j].id], dist[i][j].leng) || egal(cdist[dist[i][j].id][dist[i][o].id], dist[i][j].leng))
ans++;
}
}
g << ans;
return 0;
}