见《数学与程序设计》P255
program poj3440;
var
p,q,m,n,i,j,k:longint;
squ,s,c,t:extended;
begin
read(p);
for q:=1 to p do
begin
writeln('Case ',q,':');
read(n,m,t,c);
c:=c/2;
squ:=n*t*m*t;
s:=(t-c)*(t-c)*4+(t-2*c)*(t-c)*2*(n+m-4)+(t-2*c)*(t-2*c)*(n-2)*(m-2);
writeln('Probability of covering 1 tile = ',s/squ*100:0:4,'%');
s:=(t-2*c)*(2*c)*((n-1)*(m-2)+(m-1)*(n-2))+(t-c)*(2*c)*2*(n+m-2);
writeln('Probability of covering 2 tiles = ',s/squ*100:0:4,'%');
s:=((2*c)*(2*c)-pi*c*c)*(n-1)*(m-1);
writeln('Probability of covering 3 tiles = ',s/squ*100:0:4,'%');
s:=pi*c*c*(n-1)*(m-1);
writeln('Probability of covering 4 tiles = ',s/squ*100:0:4,'%');
writeln;
end;
end.