递推,不解释。
var
f:array[0..20,0..20,0..20,0..1] of longint;
n,m,i,j,k:longint;
begin
fillchar(f,sizeof(f),0);
readln(n,m);
for i:=1 to n do begin
f[i,0,0,0]:=1;
f[0,i,0,1]:=1;
end;
for i:=1 to n do
for j:=1 to n do
for k:=1 to m do begin
f[i,j,k,0]:=f[i-1,j,k,0]+f[i-1,j,k-1,1];
f[i,j,k,1]:=f[i,j-1,k,1]+f[i,j-1,k-1,0];
end;
writeln(f[n,n,m,0]+f[n,n,m,1]);
end.