Cod sursa(job #936312)

Utilizator DaNutZ2UuUUBB Bora Dan DaNutZ2UuU Data 6 aprilie 2013 18:18:49
Problema Medie Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#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;
}