Cod sursa(job #899463)

Utilizator Lokycatalin petre Loky Data 28 februarie 2013 14:37:45
Problema Triang Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.84 kb
#include <fstream>
#include <cmath>
#include <algorithm>

#define eps 0.001

using namespace std;

inline double distanta (double a,double b,double c,double d)
{
    double dist;
    dist=sqrt((a-b)*(a-b)+(c-d)*(c-d));
    return dist;
}

long int n,i,j,k,numar;
double a[1505],b[1505],r,t,z;
int main()
{
    ifstream f("triang.in");
    ofstream g("triang.out");

    f>>n;
    for (i=1;i<=n;i++)
        f>>a[i]>>b[i];
        numar=0;

    for (i=1;i<=n-2;i++)
        for (j=i+1;j<=n-1;j++) {
            r=distanta(a[i],a[j],b[i],b[j]);
            for (k=j+1;k<=n;k++) {
               t=distanta(a[i],a[k],b[i],b[k]);
                z=distanta(a[j],a[k],b[j],b[k]);
            }
            if (abs(r-t)<eps &&abs(r-z)<eps) numar++;
        }

    g<<numar;
    f.close();
    g.close();
    return 0;
}