Cod sursa(job #1072130)

Utilizator teodor98Teodor Sz teodor98 Data 3 ianuarie 2014 23:48:18
Problema Numarare triunghiuri Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <fstream>
#define N 801
int v[N], m[3*N][4],n,nr=0;
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
bool is_triunghi(int a,int b,int c)
{
    return ((a<=b+c && b<=a+c && c<=a+b) && (a>0 && b>0 && c>0));
}

void subsir()
{
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int p=1;p<=n;p++)
                if((((i!=p) && (j!=p) && (i!=j))&&((i<j) && (j<p)))&&(is_triunghi(v[i],v[j],v[p])))
                        nr++;

                //scrie_in_matrice(i,j,p);

}
void citire()
{
    in >> n;
    for(int i=1;i<=n;i++)
        in >> v[i];
}
int main()
{
    citire();
   subsir();
    out << nr;
    return 0;
}