Cod sursa(job #2002277)
Utilizator | Data | 19 iulie 2017 12:04:42 | |
---|---|---|---|
Problema | Numarare triunghiuri | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
using namespace std;
int n,v[807],cnt=0;
int main()
{
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
fin>>n;
for(int i=1; i<=n; i++) fin>>v[i];
for(int x=1; x<=n-2; x++)
{
for(int y=x+1; y<=n-1; y++)
{
for(int z=y+1; z<=n; z++)
{
if(v[x]+v[y]>=v[z]&&v[x]+v[z]>=v[y]&&v[z]+v[y]>=v[x]) cnt++;
}
}
}
fout<<cnt;
}