Cod sursa(job #927009)
Utilizator | Data | 25 martie 2013 15:28:49 | |
---|---|---|---|
Problema | Medie | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("medie.in");
ofstream fout("medie.out");
int n, a[9007], v[7007];
long long rez;
void Citire(){
fin>>n;
for(int i=1; i<=n; i++){
fin>>a[i];
for(int j=1; j<i; j++)
if(((a[i] + a[j])&1) == 0)
{
int x = ((a[i]+a[j])>>1);
v[x]++;
if(a[i] == x) rez--;
if(a[j] == x) rez--;
}
}
}
int main()
{
Citire();
for(int i=1; i<=n; i++)
rez += v[a[i]];
fout<<rez;
return 0;
}