Pagini recente » Cod sursa (job #2462853) | Cod sursa (job #2640473) | Cod sursa (job #625275) | Cod sursa (job #2132703) | Cod sursa (job #421573)
Cod sursa(job #421573)
type vector=array[1..20] of integer;
var v:vector;
n,p,h:integer;
{////////////////////////////}
{//////////validare//////////}
function valid(v:vector;k:integer):boolean;
var ok:boolean;
i:integer;
begin
ok:=true;
for i:=1 to k-1 do
if v[k]=v[i] then
ok:=false;
valid:=ok;
end;
{/////////////////////////////}
procedure bk(var v:vector;n:integer);
var cont:boolean;
k:integer;
begin
k:=1;
v[k]:=0;
while k>0 do
begin
cont:=false;
while (v[k]<n) and (not cont) do
begin
v[k]:=v[k]+1;
if valid(v,k) then
cont:=true;
end;
if not cont then
k:=k-1
else
if k=n then
h:=h+1
else
begin
k:=k+1;
v[k]:=0;
end;
end;
end;
begin
assign(input,'copii.in');
assign(output,'copii.out');
reset(input);
read(n);
close(input);
bk(v,n);
rewrite(output);
write(h div 2);
close(output);
end.