39 lines
564 B
Text
39 lines
564 B
Text
max = 12
|
|
#
|
|
len cnt[] max
|
|
global sp[] pos .
|
|
#
|
|
fastfunc r n .
|
|
if n = 0 : return 0
|
|
c = sp[pos - n]
|
|
cnt[n] -= 1
|
|
if cnt[n] = 0
|
|
cnt[n] = n
|
|
if r (n - 1) = 0 : return 0
|
|
.
|
|
sp[pos] = c
|
|
pos += 1
|
|
return 1
|
|
.
|
|
fastproc callr n .
|
|
while r n = 1
|
|
#
|
|
.
|
|
.
|
|
proc superperm n .
|
|
pos = n
|
|
f = 1
|
|
for i = 1 to n
|
|
f *= i
|
|
le += f
|
|
.
|
|
len sp[] le
|
|
for i = 0 to n : cnt[i] = i
|
|
for i = 1 to n : sp[i - 1] = i
|
|
callr n
|
|
.
|
|
for n = 0 to max - 1
|
|
write "superperm(" & n & ") "
|
|
superperm n
|
|
print "len = " & len sp[]
|
|
.
|