直接暴力枚举四个点,然后判断是否能组成矩形就行了
注意枚举的点的标号从小到大,保证不重复枚举
/**************************************************************
Problem:
User: BLADEVIL
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/
//By BLADEVIL
var
n :longint;
sum :array[..] of longint;
i, j, k, l :longint;
a, b, c, d :longint;
tot, ans :longint;
function min(a,b:longint):longint;
begin
if a>b then min:=b else min:=a;
end;
begin
read(n);
for i:= to n+ do read(sum[i]);
for i:= to n+ do inc(tot,sum[i]);
for i:= to n do sum[i]:=sum[i]+sum[i-];
for i:= to n do
for j:=i+ to n do
for k:=j+ to n do
for l:=k+ to n do
begin
a:=sum[j]-sum[i];
a:=min(tot-a,a);
b:=sum[k]-sum[j];
b:=min(tot-b,b);
c:=sum[l]-sum[k];
c:=min(c,tot-c);
d:=abs(sum[l]-sum[i]);
d:=min(d,tot-d);
if (a=c) and (b=d) then inc(ans);
end;
writeln(ans);
end.