记录编号 |
2305 |
评测结果 |
AATTAAAATA |
题目名称 |
[NOI 1999]棋盘分割 |
最终得分 |
70 |
用户昵称 |
SMXX |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
3.481 s |
提交时间 |
2008-09-17 21:31:00 |
内存使用 |
0.11 MiB |
显示代码纯文本
program fd;
var
f1,f2:text;
ans,e:real;
n,i,k,j:integer;
a:array[1..8,1..8]of integer;
b:array[1..15]of record x1,x2,y1,y2:integer; end;
function min(a,b:real):real;
begin
if a<b then min:=a
else min:=b;
end;
function tt:real;
var
r:real;
s,k,h,i:integer;
d:array[1..15]of integer;
begin
for i:= 1to n do begin
s:=0;
for k:= b[i].x1 to b[i].x2-1 do
for h:=b[i].y1 to b[i].y2-1 do
s:=s+a[k,h];
d[i]:=s;
end;
r:=0;
for i:= 1to n do r:=r+(d[i]-e)*(d[i]-e);
tt:=sqrt(r/n);
end;
procedure main(a:integer);
var
i,j,k:integer;
begin
if a=n then ans:=min(ans,tt) else begin
for k:=1 to a do begin
for i:=b[k].x1+1 to b[k].x2-1 do begin
b[a+1].x1:=i;b[a+1].y1:=b[k].y1;
b[a+1].x2:=b[k].x2;b[a+1].y2:=b[k].y2;
b[k].x2:=i;
main(a+1);
b[k].x2:=b[a+1].x2;
end;
for j:=b[k].y1+1to b[k].y2-1 do begin
b[a+1].x1:= b[k].x1;b[a+1].y1:=j;
b[a+1].x2:=b[k].x2;b[a+1].y2:=b[k].y2;
b[k].y2:=j;
main(a+1);
b[k].y2:=b[a+1].y2;
end;
end;
end;
end;
begin
assign(f1,'division.in');
assign(f2,'division.out');
reset(f1);
rewrite(f2);
readln(f1,n);
for i:= 1to 8 do
for j:= 1to 8 do begin
read(f1,a[i,j]);k:=k+a[i,j];
end;
e:=k/n;
ans:=1000000000;
b[1].x1:=1;b[1].y1:=1;
b[1].x2:=9;b[1].y2:=9;
main(1);
writeln(f2,ans:0:3);
close(f1);
close(f2);
end.