Pagini recente » Cod sursa (job #2789671) | Cod sursa (job #2902104) | Cod sursa (job #1810932) | Cod sursa (job #1254999) | Cod sursa (job #120195)
Cod sursa(job #120195)
var v:array[1..9000]of longint;
x,y:array[1..7000]of longint;
i,j,n,s:longint;
procedure qsort(ls,ld:longint);
var i,j,aux:longint;
begin
i:=ls;j:=ld;
while true do begin
while (v[i]<=v[j])and(i<>j) do inc(i);
if i=j then break;
aux:=v[i];v[i]:=v[j];v[j]:=aux;dec(j);
while (v[i]<=v[j])and(i<>j) do dec(j);
if i=j then break;
aux:=v[i];v[i]:=v[j];v[j]:=aux;inc(i);
end;
if j-1>ls then qsort(ls,j-1);
if j+1<ld then qsort(j+1,ld);
end;
begin
assign(input,'medie.in');reset(input);
assign(output,'medie.out');rewrite(output);
readln(n);
for i:=1 to n do
begin
read(v[i]);
inc(x[v[i]]);
end;
//qsort(1,n);
for i:=1 to n-1 do
for j:=i+1 to n do
begin
if (v[i]+v[j]) mod 2=0 then
inc(y[(v[i]+v[j]) shr 1]);
end;
for i:=1 to n do
if y[v[i]]<>0 then
s:=s+y[v[i]]-x[v[i]]+1;
writeln(s);
close(input);close(output);
end.