比赛 |
20121107 |
评测结果 |
WWWWW |
题目名称 |
三只小猪 |
最终得分 |
0 |
用户昵称 |
FrCsKOH |
运行时间 |
0.077 s |
代码语言 |
Pascal |
内存使用 |
0.18 MiB |
提交时间 |
2012-11-07 10:45:00 |
显示代码纯文本
program C1255;
var f:array[0..50,0..50] of ansistring;
C:array[1..1000] of integer;
n,m,i,j,l,T,lenA,lenB,len:longint;
function Plus(A,B:ansistring):ansistring;
var i:longint;
begin
lenA:=length(A);
lenB:=length(B);
if lenA>lenB then len:=lenA else len:=lenB;
fillchar(C,sizeof(C),0);
for i:=1 to lenA do C[lenA-i+1]:=ord(A[i])-48;
for i:=1 to lenB do inc(C[lenB-i+1],ord(B[i])-48);
for i:=1 to len do begin
inc(C[i+1],C[i] div 10);
C[i]:=C[i] mod 10;
end;
if C[len+1]<>0 then inc(len);
Plus:='';
for i:=1 to len do Plus:=chr(C[i]+48)+Plus;
end;
function SingalMult(k:longint;A:ansistring):ansistring;
var i:longint;
begin
lenA:=length(A);
fillchar(C,sizeof(C),0);
for i:=1 to lenA do C[lenA-i+1]:=ord(A[i])-48;
for i:=1 to lenA do C[i]:=C[i]*k;
for i:=1 to lenA do begin
inc(C[i+1],C[i] div 10);
C[i]:=C[i] mod 10;
end;
while C[lenA+1]<>0 do inc(lenA);
SingalMult:='';
for i:=1 to lenA do SingalMult:=chr(C[i]+48)+SingalMult;
end;
begin
assign(input,'piggy.in');
reset(input);
assign(output,'piggy.out');
rewrite(output);
readln(T);
for l:=1 to T do begin
readln(n,m);
for i:=1 to m do f[i,i]:='1';
for i:=1 to n do f[i,1]:='1';
for i:=2 to n do
for j:=2 to m do
f[i,j]:=Plus(f[i-1,j-1],SingalMult(j,f[i-1,j]));
writeln(f[n,m]);
end;
close(input);
close(output);
end.