Cod sursa(job #1670924)

Utilizator superstar1998Moldoveanu Vlad superstar1998 Data 1 aprilie 2016 10:31:26
Problema Triang Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <iostream>
#include <fstream>
#include <cmath>
#define MAXN 1501
#define INFILE "triang.in"
#define OUTFILE "triang.out"
#define eps 0.001
using namespace std;
ifstream f(INFILE);
ofstream g(OUTFILE);
int n,k,l;
double v[MAXN][2],aux;
inline double dist(double x1, double y1, double x2, double y2)
{
    return ((x1-x2)*(x1-x2)+(y2-y1)*(y2-y1));
}
int main()
{
    f>>n;
    for(int i=1;i<=n;i++)
        f>>v[i][0]>>v[i][1];
    for(int i=1,j,l;i<n-1;i++)
        for(j=i+1;j<n;j++)
        {
            aux=dist(v[i][0],v[i][1],v[j][0],v[j][1]);
            for(l=j+1;l<=n;l++)
                if(abs(aux-dist(v[i][0],v[i][1],v[l][0],v[l][1]))<eps&&abs(aux-dist(v[j][0],v[j][1],v[l][0],v[l][1]))<eps)k++;
        }
    g<<k;
    f.close();
    g.close();
    return 0;
}