Pagini recente » Cod sursa (job #981908) | Cod sursa (job #936312)
Cod sursa(job #936312)
#include <fstream>
using namespace std;
ifstream fin("medie.in"); ofstream fout("medie.out");
int a[9001], b[7001], sum, n;
int main()
{
int x;
fin >> n;
for(int i = 1; i <= n; i++)
fin >> a[i];
for(int i = 1; i < n; i++)
for(int j = i + 1 ; j <= n; j++)
if((a[i] + a[j]) % 2 == 0)
{
x = (a[i] + a[j])/2;
b[x]++;
if(a[i] == a[j])
sum -= 2;
}
for(int i = 1; i <= n; i++)
sum += b[a[i]];
fout << sum << "\n";
fin.close(); fout.close();
return 0;
}