Cod sursa(job #571682)

Utilizator TeodoraTanaseTeodora Tanase TeodoraTanase Data 4 aprilie 2011 18:08:51
Problema Medie Scor 100
Compilator cpp Status done
Runda brasov_11_jr Marime 0.5 kb
#include <cstdio>

using namespace std;

const int M=9009;
int n, a[M], ap[M];

int main()
{
    freopen ("medie.in","r",stdin);
    freopen ("medie.out","w",stdout);
    scanf ("%d ",&n);
    for (int i=0; i<n; ++i)
    {
        scanf ("%d ",&a[i]);
        for (int j=i-1; j>=0; --j)
            if ((a[i]+a[j])%2==0)
                ++ap[(a[i]+a[j])>>1];
        --ap[a[i]];
    }
    int nr=0;
    for (int i=0; i<n; ++i)
        nr+=ap[a[i]]+1;
    printf ("%d\n",nr);
    return 0;
}