|
|
back to boardWA 1 var n,k,tc:integer; a:array [1..20] of integer; procedure gen(x:integer); var i:integer; begin if x = n+1 then inc(tc) else begin if x=1 then for i:=1 to k-1 do begin a[x]:=i; gen(x+1); end else for i:=0 to k-1 do begin a[x]:=i; if (a[x-1]=0) then begin if (i=0) then begin inc(x); dec(x); end; end else gen(x+1); end; end; end; begin readln(n); readln(k); gen(1); writeln(tc); end. What is it! |
|
|