比赛 |
搜索题... |
评测结果 |
AAAAAAAAEA |
题目名称 |
跳马问题 |
最终得分 |
90 |
用户昵称 |
稠翼 |
运行时间 |
0.081 s |
代码语言 |
Pascal |
内存使用 |
0.78 MiB |
提交时间 |
2014-11-04 19:28:04 |
显示代码纯文本
program cogs49;
const
dx:array[1..4]of longint=(1,1,2,2);
dy:array[1..4]of longint=(2,-2,1,-1);
type nod=record
x,y:longint;
end;
var
i,x,y,h,t,n,m:longint;
q:array[0..80000]of nod;
d:array[0..20,0..20]of longint;
procedure init;
begin
assign(input,'horse.in');reset(input);
assign(output,'horse.out');rewrite(output);
end;
procedure main;
begin
readln(n,m);
h:=0;t:=1;q[1].x:=1;q[1].y:=1;
d[1,1]:=1;
while h<t do
begin
inc(h);
for i:=1 to 4 do
begin
x:=q[h].x+dx[i];y:=q[h].y+dy[i];
if (x>1)and(x<=m)and(y>=1)and(y<=n) then
begin
inc(t);
q[t].x:=x;q[t].y:=y;
d[x,y]:=d[x,y]+1;
end;
end;
end;
writeln(d[m,n]);
end;
begin
init;
main;
end.