您的位置:首页 > 其它

bzoj 1800 暴力枚举

2014-01-01 20:15 302 查看
直接暴力枚举四个点,然后判断是否能组成矩形就行了

注意枚举的点的标号从小到大,保证不重复枚举

/**************************************************************
Problem: 1800
User: BLADEVIL
Language: Pascal
Result: Accepted
Time:0 ms
Memory:224 kb
****************************************************************/

//By BLADEVIL
var
n                           :longint;
sum                         :array[0..21] 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:=2 to n+1 do read(sum[i]);
for i:=2 to n+1 do inc(tot,sum[i]);
for i:=1 to n do sum[i]:=sum[i]+sum[i-1];
for i:=1 to n do
for j:=i+1 to n do
for k:=j+1 to n do
for l:=k+1 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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: