记录编号 |
6327 |
评测结果 |
AATTAAAATA |
题目名称 |
[NOI 1999]棋盘分割 |
最终得分 |
70 |
用户昵称 |
EnAsn |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
3.545 s |
提交时间 |
2008-10-31 22:12:59 |
内存使用 |
0.11 MiB |
显示代码纯文本
program ex;
type
data=record
x1,y1,x2,y2:integer;
end;
ss=array[1..15]of data;
sz=array[1..15,1..15]of integer;
sh=array[1..15]of integer;
var
a:ss;
f:sz;
z:sh;
f1,f2:text;
n:integer;
xb,ans:real;
procedure init;
var
i,j:integer;
begin
assign(f1,'division.in');
assign(f2,'division.out');
reset(f1);
rewrite(f2);
readln(f1,n);
for i:=1 to 8 do
begin
for j:=1 to 8 do
begin
read(f1,f[i,j]);
xb:=xb+f[i,j];
end;
readln(f1);
end;
close(f1);
xb:=xb/n;
a[1].x1:=1; a[1].y1:=1;
a[1].x2:=8; a[1].y2:=8;
ans:=maxint;
end;
procedure pd;
var
i,j,k:integer;
q:real;
begin
fillchar(z,sizeof(z),0);
for k:=1 to n do
for i:=a[k].x1 to a[k].x2 do
for j:=a[k].y1 to a[k].y2 do
z[k]:=z[k]+f[i,j];
q:=0;
for i:=1 to n do
q:=q+(z[i]-xb)*(z[i]-xb);
q:=q/n;
q:=sqrt(q);
if q<ans then ans:=q;
end;
procedure try(step:integer);
var
i,j,k:integer;
step1:integer;
c:data;
begin
for k:=1 to step-1 do
begin
c:=a[k];
for i:=c.x1+1 to c.x2 do
begin
a[step].x1:=i;
a[step].y1:=c.y1;
a[step].x2:=c.x2;
a[step].y2:=c.y2;
a[k].x2:=i-1;
if step=n then pd
else try(step+1);
a[k].x2:=c.x2;
end;
for j:=c.y1+1 to c.y2 do
begin
a[step].x1:=c.x1;
a[step].y1:=j;
a[step].x2:=c.x2;
a[step].y2:=c.y2;
a[k].y2:=j-1;
if step=n then pd
else try(step+1);
a[k].y2:=c.y2;
end;
end;
end;
begin
init;
{if n=4 then begin
writeln(f2,'0.000');
close(f2);
halt;
end;}
try(2);
writeln(f2,ans:0:3);
close(f2);
end.