比赛 暑假培训七 评测结果 AEATTT
题目名称 过河卒 最终得分 20
用户昵称 苏轼 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-24 16:48:26
显示代码纯文本
program cch(input,output,f1,f2);
const
 xx:array[1..2]of integer= (1,0);
 yy:array[1..2]of integer=(0,1);
var
 f1,f2:text;
 a:array[0..20,0..20] of boolean;
 i,j,x1,y1,x2,y2:integer;
 c:longint;

procedure search(x,y:integer);
var
 i,j,x3,y3:integer;
begin
 if (x=x1)and(y=y1) then begin inc(c);
                               exit;
                         end;
  for i:=1 to 2 do begin
   x3:=x+xx[i]; y3:=y+yy[i];
   if (x3 in [0..x1])and(y3 in [0..y1]) then
    if a[x3,y3] then search(x3,y3);
  end;
end;

begin
 assign(f1,'pj024.in');
 assign(f2,'pj024.out');
 reset(f1);
 rewrite(f2);
 readln(f1,x1,y1,x2,y2);
 for i:=0 to x1 do
  for j:=0 to y1 do a[i,j]:=true;
 a[x2-2,y2+1]:=false; a[x2-1,y2+2]:=false; a[x2+1,y2+2]:=false;
 a[x2+2,y2+1]:=false; a[x2+2,y2-1]:=false; a[x2+1,y2-2]:=false;
 a[x2-1,y2-2]:=false; a[x2-2,y2-1]:=false; a[x2,y2]:=false;
 c:=0;
 search(0,0);
 writeln(f2,c);
 close(f1);
 close(f2);
end.