Cod sursa(job #350677)
| Utilizator | Data | 25 septembrie 2009 12:29:04 | |
|---|---|---|---|
| Problema | Numarare triunghiuri | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include<fstream>
#define Max 800
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,a[Max],x[Max],p;
void test(){
if(a[x[1]]+a[x[2]] >= a[x[3]] && a[x[2]]+a[x[3]] >= a[x[1]] && a[x[1]]+a[x[3]] >= a[x[2]])
p+=1;
}
void comb(int k){
int i;
for(i = x[k-1]+1; i <= n-3+k;i++)
{
x[k] = i;
if(k == 3)test();
else
comb(k+1);
}
}
int main(){
int i;
fin>>n;
for(i = 1;i <= n; i++)
fin>>a[i];
comb(1);
fout<<p;
fin.close();
fout.close();
return 0;
}
