比赛 |
NOIP_3 |
评测结果 |
AWAWWAAWWA |
题目名称 |
棋盘分割 |
最终得分 |
50 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-10-19 10:09:37 |
显示代码纯文本
program cch(input,output);
const
maxm=10000000000;
var
a:array[1..8,1..8] of integer;
ans:array[1..20] of longint;
num:array[1..8,1..8,1..8,1..8] of longint;
i,j,k,p,r,w,n:integer;
min,x0:real;
procedure search(k,x1,x2,y1,y2:integer);
var
i,j:integer;
tot:real;
begin
if k=n then
begin
ans[k]:=num[x1,x2,y1,y2];
tot:=0;
for j:=1 to n do
tot:=tot+sqr(ans[j]-x0);
if sqrt(tot/n)<min then min:=sqrt(tot/n);
end;
for i:=x1 to x2-1 do
begin
ans[k]:=num[x1,i,y1,y2];
search(k+1,i+1,x2,y1,y2);
end;
for i:=y1 to y2-1 do
begin
ans[k]:=num[x1,x2,y1,i];
search(k+1,x1,x2,i+1,y2);
end;
end;
begin
assign(input,'division.in');
assign(output,'division.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to 8 do
for j:=1 to 8 do read(a[i,j]);
for i:=1 to 8 do
for j:=i to 8 do
for k:=1 to 8 do
for p:=k to 8 do
begin
num[i,j,k,p]:=0;
for r:=i to j do
for w:=k to p do
inc(num[i,j,k,p],a[r,w]);
end;
x0:=num[1,8,1,8]/n; min:=maxm;
search(1,1,8,1,8);
write(min:0:3);
close(input);
close(output);
end.