Cod sursa(job #1522058)

Utilizator sabin.antoheSabin Antohe sabin.antohe Data 11 noiembrie 2015 10:11:35
Problema Numarare triunghiuri Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include<fstream>
#include<algorithm>
#include<iostream>
using namespace std;

int v[1000];
int n;

bool verify(int a, int b, int c) {
  return ((a <= b + c) && (b <= a + c) && (c <= a + b));
}

int main(void) {
  ifstream fin("nrtri.in");
  ofstream fout("nrtri.out");

  fin >> n;
  for(int i = 0; i < n; i++)
    fin >> v[i];

  int nr = 0;

  for(int i = 0; i < n; i++)
    for(int j = i+1; j < n; j++) 
      for(int k = 0; k < n; k++)
        if((k !=i && k !=j) && verify(v[i], v[j], v[k]))
          nr++;

    fout << nr / 3;
}