记录编号 |
49541 |
评测结果 |
AAAAAAAAAA |
题目名称 |
K 上升段 |
最终得分 |
100 |
用户昵称 |
极寒之魇 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.088 s |
提交时间 |
2012-11-08 14:29:39 |
内存使用 |
10.24 MiB |
显示代码纯文本
uses math;
type ar=array[0..1000] of longint;
var f:array[0..50,0..50] of ar;
bw,bw1:ar;
i,j,n,t,k,x,y:longint;
function add(x,y:ar):ar;
var a,b,c:ar;
t,n,i,m:longint;
begin
fillchar(c,sizeof(c),0);
fillchar(b,sizeof(b),0);
fillchar(a,sizeof(a),0);
a:=x; b:=y; n:=max(a[0],b[0]);
t:=0; m:=0;
for i:=1 to n do
begin
m:=a[i]+b[i]+t;
c[i]:=m mod 10;
t:=m div 10;
end;
if t<>0 then begin c[0]:=n+1; c[n+1]:=t; end else c[0]:=n;
exit(c);
end;
function cheng(x:longint;y:ar):ar;
var b,c:ar;
t,n,i,m,a:longint;
begin
fillchar(c,sizeof(c),0);
fillchar(b,sizeof(b),0);
a:=x; b:=y; n:=b[0]; t:=0; m:=0;
for i:=1 to n do
begin
m:=a*b[i]+t;
c[i]:=m mod 10;
t:=m div 10;
end;
if t<>0 then begin c[0]:=n+1; c[n+1]:=t; end else c[0]:=n;
exit(c);
end;
begin
assign(input,'k.in'); reset(input);
assign(output,'k.out'); rewrite(output);
fillchar(f,sizeof(f),0);
for i:=1 to 50 do begin f[i,1][1]:=1; f[i,1][0]:=1; f[i,i][1]:=1; f[i,i][0]:=1;
end;
readln(x,y);
if x<y then begin writeln(0); end;
if f[x,y][0]<>0 then begin writeln(f[x,y][0]); halt; end;
for i:=1 to x do
for j:=1 to y do
if ((i>j) and (f[i,j][0]=0)) then begin bw:=cheng(i-j+1,f[i-1,j-1]);
bw1:=cheng(j,f[i-1,j]);
f[i,j]:=add(bw,bw1); end;
for i:=f[x,y][0] downto 1 do
write(f[x,y][i]);
writeln;
close(output);
end.