比赛 |
NOIP2008集训模拟1 |
评测结果 |
AAAAAAAAAA |
题目名称 |
地铁重组 |
最终得分 |
100 |
用户昵称 |
thegy |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-10 11:21:22 |
显示代码纯文本
program subway;
var
fin,fout:text;
n,p:longint;
f:array[0..500,0..300]of longint;
v:array[0..500,0..300]of boolean;
procedure jyhss(x,y:longint);
var
t1,t2:longint;
begin
if (x=0) and (y=0) then begin
f[0,0]:=1;
v[0,0]:=true;
exit;
end;
if (x<>0) and (y+1<=p) then begin
if not(v[x-1,y+1]) then jyhss(x-1,y+1);
t1:=f[x-1,y+1];
end else t1:=0;
if y<>0 then begin
if not(v[x,y-1]) then jyhss(x,y-1);
t2:=f[x,y-1];
end else t2:=0;
f[x,y]:=(t1+t2) mod 4096;
v[x,y]:=true;
end;
begin
assign(fin,'subway.in'); reset(fin);
assign(fout,'subway.out'); rewrite(fout);
read(fin,n,p);
jyhss(n,0);
writeln(fout,f[n,0]);
close(fin);
close(fout);
end.