Pagini recente » Cod sursa (job #2253065) | Statistici Ionescu Daria (ionescudaria) | Profil Leuici | Cod sursa (job #2190445) | Cod sursa (job #2035299)
#include<bits/stdc++.h>
using namespace std;
int n, a[801];
int Search(int l, int r, int v)
{
int m;
while (l <= r)
{
m = (l + r) / 2;
if (a[m] == v)
return v;
else
{
if(a[m] > v)
r = m - 1;
else
l = m + 1;
}
}
return -1;
}
int main()
{
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n, cnt = 0;
fin >> n;
for(int i = 1; i <= n; ++i)
fin >> a[i];
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
if(i != j && Search(1, n, a[i] + a[j]) >= a[i] + a[j])
cnt++;
fout << cnt;
return 0;
}