- 珠心算测验
- 2016-08-24 13:49:02 @
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 条评论
-
唐复之 LV 8 @ 2016-08-25 09:29:50
呵呵
-
2016-08-25 09:29:35@
呵呵
-
2016-08-25 09:29:25@
呵呵
-
2016-08-25 09:28:11@
hehe
- 1
信息
- ID
- 1911
- 难度
- 6
- 分类
- (无)
- 标签
- 递交数
- 17109
- 已通过
- 4523
- 通过率
- 26%
- 被复制
- 28
- 上传者