记录编号 4805 评测结果 AATTAAAATA
题目名称 [NOI 1999]棋盘分割 最终得分 70
用户昵称 Gravatar打不死的羊 是否通过 未通过
代码语言 Pascal 运行时间 6.543 s
提交时间 2008-10-22 20:17:56 内存使用 0.11 MiB
显示代码纯文本
program division;
Type
fxz1=array[1..8,1..8]of integer;
fxz2=record
     x1,x2,y1,y2:integer;
     end;
fxz3=array[1..15] of fxz2;
var
min,pj:real;
i,j,n:integer;
map:fxz1;
f1,f2:text;
lm:fxz3;
procedure sc(k:integer);
var
i,j,p,q:integer;
ls:fxz2;
   procedure pan;
   var
   i,j,p,q:longint;
   ppjj,m,mm:real;
   begin
   mm:=0;
   for i:=1 to n do
   begin
   m:=0;
   for p:=lm[i].x1 to lm[i].x2 do
   for q:=lm[i].y1 to lm[i].y2 do
   m:=m+map[p,q];
   mm:=mm+sqr(m-pj);
   end;
   ppjj:=mm/n;
   if ppjj<min then min:=ppjj;
   end;
begin
 for i:=1 to k-1 do
  begin
  ls:=lm[i];
   for p:=ls.x1+1 to ls.x2 do
   begin
   lm[k].x1:=p;lm[k].x2:=ls.x2;
   lm[k].y1:=ls.y1;lm[k].y2:=ls.y2;
   lm[i].x2:=p-1;
   if k=n then pan
          else sc(k+1);
   lm[i].x2:=ls.x2;
   if min=0 then exit;
   end;
   for q:=ls.y1+1 to ls.y2 do
   begin
   lm[k].x1:=ls.x1;lm[k].x2:=ls.x2;
   lm[k].y1:=q;lm[k].y2:=ls.y2;
   lm[i].y2:=q-1;
   if k=n then pan
          else sc(k+1);
   lm[i].y2:=ls.y2;
   if min=0 then exit;
   end;
 end;
 end;
{...................................................................}
begin
assign(f1,'division.in');
assign(f2,'division.out');
reset(f1);rewrite(f2);
readln(f1,n);
pj:=0;
for i:=1 to 8 do
begin
for j:=1 to 8 do
begin
read(f1,map[i,j]);
pj:=pj+map[i,j];
end;
readln(f1);
end;
min:=99999999;
pj:=pj/n;
{...................................................................}
with lm[1] do
begin
x1:=1;x2:=8;
y1:=1;y2:=8;
end;
sc(2);
writeln(f2,sqrt(min):0:3);
close(f1);close(f2);
end.