记录编号 |
4910 |
评测结果 |
AATTAAAATA |
题目名称 |
[NOI 1999]棋盘分割 |
最终得分 |
70 |
用户昵称 |
rottenwood |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
6.699 s |
提交时间 |
2008-10-23 13:32:15 |
内存使用 |
0.11 MiB |
显示代码纯文本
program division;
type
shuzu=array[1..8,1..8] of integer;
shuzu1=array[1..15,1..4] of integer;
var
f:shuzu1;
s:shuzu;
i,j,k,m,n:longint;
ans,ba:real;
function zhaomin(x,y:real):real;
begin
if x>y then zhaomin:=y
else zhaomin:=x;
end;
function jisuan:real;
var
i,j,k:integer;
a:array[1..15] of real;
c:real;
begin
for i:=1 to 15 do a[i]:=0;
for k:=1 to n do
begin
c:=0;
for i:=f[k,1] to f[k,3]-1 do
for j:=f[k,2] to f[k,4]-1 do
c:=c+s[i,j];
a[k]:=c;
end;
c:=0;
for k:=1 to n do
c:=c+(a[k]-ba)*(a[k]-ba);
jisuan:=sqrt(c/n);
end;
procedure dg(t:integer);
var
i,j,k,temp:integer;
begin
if t<n then
BEGIN
for k:=1 to t do
begin
for i:=f[k,1]+1 to f[k,3]-1 do
begin
f[t+1,1]:=i;f[t+1,2]:=f[k,2];
f[t+1,3]:=f[k,3];f[t+1,4]:=f[k,4];
f[k,3]:=i;
dg(t+1);
f[k,3]:=f[t+1,3];
end;
for j:=f[k,2]+1 to f[k,4]-1 do
begin
f[t+1,1]:=f[k,1];f[t+1,2]:=j;
f[t+1,3]:=f[k,3];f[t+1,4]:=f[k,4];
f[k,4]:=j;
dg(t+1);
f[k,4]:=f[t+1,4];
end;
end;
end
else
ans:=zhaomin(ans,jisuan);
end;
begin
assign(input,'division.in');reset(input);
assign(output,'division.out');rewrite(output);
readln(n);
for i:=1 to 8 do
begin
for j:=1 to 8 do begin
read(s[i,j]); ba:=ba+s[i,j]; end;
readln;
end;
ans:=maxint; ba:=ba/n;
f[1,1]:=1; f[1,2]:=1; f[1,3]:=9; f[1,4]:=9;
dg(1);
writeln(ans:0:3);
close(output);
end.