BCDIV - Chia nhóm
Tác giả: ll931110
Ngôn ngữ: Pascal
{$R+,Q+}
program BCDIV;
const
input = '';
output = '';
maxn = 25;
var
fi,fo: text;
F: array[1..maxn,1..maxn] of int64;
n,k: longint;
procedure openfile;
begin
assign(fi, input); reset(fi);
assign(fo, output); rewrite(fo);
end;
procedure closefile;
begin
close(fo);
close(fi);
end;
procedure dp;
var
i,j: longint;
begin
for i := 1 to maxn do F[i,1] := 1;
for j := 2 to maxn do
for i := j to maxn do
F[i,j] := j * F[i - 1,j] + F[i - 1,j - 1];
end;
procedure solve;
var
i,nTest: longint;
begin
readln(fi, nTest);
for i := 1 to nTest do
begin
readln(fi, n, k);
writeln(fo, F[n,k]);
end;
end;
begin
openfile;
dp;
solve;
closefile;
end.