求教

var
n,i,j,k,ans:longint;
a:array[1..10000] of longint;
procedure qsort(l,r:longint);
var
i,j,mid,p:longint;
begin
i:=l;
j:=r;
mid:=a[(l+r) div 2];
repeat
while a[i]<mid do inc(i);
while a[j]>mid do dec(j);
if i<=j then begin
p:=a[i]; a[i]:=a[j]; a[j]:=p;
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
ans:=0;
readln(n);
for i:=1 to n do begin
read(a[i]);
end;
readln;
qsort(1,n);
for i:=3 to n do begin
for j:=1 to i-2 do begin
for k:=j+1 to i-1 do begin
if a[j]+a[k]=a[i] then inc(ans);
end;
end;
end;
writeln(ans);
end.

4 条评论

  • 1

信息

ID
1911
难度
6
分类
(无)
标签
递交数
17109
已通过
4523
通过率
26%
被复制
28
上传者