记录编号 |
4589 |
评测结果 |
AATTAAAATA |
题目名称 |
[NOI 1999]棋盘分割 |
最终得分 |
70 |
用户昵称 |
bing |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
6.747 s |
提交时间 |
2008-10-21 13:30:18 |
内存使用 |
0.11 MiB |
显示代码纯文本
program bing;
type
kuai=record
x1,x2,y1,y2:integer;
end;
var
f1,f2:text;
n:integer;
s:real;
a:array[1..15] of kuai;
b:array[1..8,1..8]of real;
procedure init;
var
i,j:Integer;
begin
assign(f1,'division.in');reset(f1);
assign(f2,'division.out');rewrite(f2);
readln(f1,n);
s:=640000;
for i:=1 to 8 do
for j:=1 to 8 do
read(f1,b[i,j]);
a[1].x1:=1;a[1].y1:=1;
a[1].x2:=8;a[1].y2:=8;
end;
procedure qiu;
var
i,j,x:Integer;
c:array[1..15] of real;
p,q:real;
begin
fillchar(c,sizeof(c),0);
for x:=1 to n do
begin
c[x]:=0;
for i:=a[x].x1 to a[x].x2 do
for j:=a[x].y1 to a[x].y2 do
c[x]:=c[x]+b[i,j];
end;
p:=0;q:=0;
for i:=1 to n do p:=p+c[i];
p:=p/n;
for i:=1 to n do q:=q+sqr(c[i]-p);
q:=q/n;
if q<s then s:=q;
end;
procedure nb(x:integer);
var
i,j,k:Integer;
begin
for i:=1 to x-1 do
begin
for j:=a[i].x1 to a[i].x2-1 do
begin
k:=a[i].x2;
a[x].x1:=j+1;a[x].y1:=a[i].y1;
a[x].x2:=a[i].x2;a[x].y2:=a[i].y2;
a[i].x2:=j;
if x=n then qiu else
nb(x+1);
a[i].x2:=k;
end;
for j:=a[i].y1 to a[i].y2-1 do
begin
k:=a[i].y2;
a[x].y1:=j+1;a[x].x1:=a[i].x1;;
a[x].y2:=a[i].y2;a[x].x2:=a[i].x2;
a[i].y2:=j;
if x=n then qiu else
nb(x+1);
a[i].y2:=k;
end;
end;
end;
begin
init;
nb(2);
write(f2,sqrt(s):0:3);
close(f1);close(f2);
end.