COND - Quan hệ
Tác giả: flashmt
Ngôn ngữ: Pascal
const fi='';
fo='';
var p:array[0..10] of int64;
a:array[2..10] of int64;
b:array[1..10] of int64;
t:longint;
function sum(i:longint):int64;
var j:longint; re:int64;
begin
re:=0;
for j:=1 to i do re:=re+b[j];
sum:=re;
end;
function mul(i:longint):int64;
var j:longint; re:int64;
begin
re:=1;
for j:=1 to i do re:=re*p[b[j]];
mul:=re;
end;
procedure find(pos,num:longint);
var i:int64;
begin
i:=0;
while i<num do
begin
inc(i);
b[pos]:=i;
if sum(pos)=num then a[num]:=a[num]+p[num] div mul(pos)
else
begin
if sum(pos)<num then find(pos+1,num)
else
begin
b[pos]:=0;
break;
end;
end;
b[pos]:=0;
end;
end;
procedure init;
var i,j:longint; t:int64;
begin
p[0]:=1; p[1]:=1;
t:=1; j:=1;
while t<10 do
begin
inc(t);
inc(j);
p[t]:=p[t-1]*t;
end;
fillchar(a,sizeof(a),0);
for i:=2 to 10 do
find(1,i);
end;
begin
init;
assign(input,fi);
reset(input);
assign(output,fo);
rewrite(output);
readln(t);
while t<>-1 do
begin
writeln(a[t]);
readln(t);
end;
close(input);
close(output);
end.