主题:马拦过河卒
const dx:array[1..8]of integer=(-2,-2,-1,-1,1,1,2,2);
dy:array[1..8]of integer=(1,-1,-2,2,2,-2,1,-1);
var a:array[-1..15,-1..15]of longint;
n,m,x,y,i,j:longint;
begin
readln(n,m,x,y);
for i:=0 to n do
for j:=0 to m do
a[i,j]:=1;
for i:=1 to 8 do
if (dx[i]+x>=0)and(dy[i]+y>=0)
then a[dx[i]+x,dy[i]+y]:=0;
for i:=1 to n do
if a[i,0]=0 then
for j:=i to n do
begin
a[j,0]:=0;
break;
end;
for i:=1 to m do
if a[0,i]=0 then
for j:=i to m do
begin
a[0,j]:=0;
break;
end;
a[x,y]:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]<>0 then a[i,j]:=a[i-1,j]+a[i,j-1];
writeln(a[n,m]);
end.
这是vijos上的1121,即马拦过河卒,为什么当答案为0时出12?(提交结果的显示)
急需,谢谢。(www.vijos.cn)[em10][em10][em10]
dy:array[1..8]of integer=(1,-1,-2,2,2,-2,1,-1);
var a:array[-1..15,-1..15]of longint;
n,m,x,y,i,j:longint;
begin
readln(n,m,x,y);
for i:=0 to n do
for j:=0 to m do
a[i,j]:=1;
for i:=1 to 8 do
if (dx[i]+x>=0)and(dy[i]+y>=0)
then a[dx[i]+x,dy[i]+y]:=0;
for i:=1 to n do
if a[i,0]=0 then
for j:=i to n do
begin
a[j,0]:=0;
break;
end;
for i:=1 to m do
if a[0,i]=0 then
for j:=i to m do
begin
a[0,j]:=0;
break;
end;
a[x,y]:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]<>0 then a[i,j]:=a[i-1,j]+a[i,j-1];
writeln(a[n,m]);
end.
这是vijos上的1121,即马拦过河卒,为什么当答案为0时出12?(提交结果的显示)
急需,谢谢。(www.vijos.cn)[em10][em10][em10]