46 lines
1,014 B
Text
46 lines
1,014 B
Text
constant MAX_N = 32,
|
|
BRANCH = 4
|
|
|
|
sequence {rooted,unrooted} @= repeat(0,MAX_N+2)
|
|
|
|
procedure tree(integer br, n, l=n, tot=1, atom cnt=1)
|
|
atom c
|
|
for b=br+1 to BRANCH do
|
|
tot += n
|
|
if tot>=MAX_N+1
|
|
or (l*2>=tot and b>=BRANCH) then
|
|
return
|
|
end if
|
|
if b==br+1 then
|
|
c = rooted[n+1]*cnt
|
|
else
|
|
c *= (rooted[n+1]+(b-br-1))/(b-br)
|
|
end if
|
|
if l*2<tot then
|
|
unrooted[tot+1] += c
|
|
end if
|
|
if b<BRANCH then
|
|
rooted[tot+1] += c
|
|
for m=1 to n-1 do
|
|
tree(b,m,l,tot,c)
|
|
end for
|
|
end if
|
|
end for
|
|
end procedure
|
|
|
|
procedure bicenter(integer s)
|
|
if mod(s,2)=0 then
|
|
atom aux = rooted[s/2+1]
|
|
unrooted[s+1] += aux*(aux+1)/2
|
|
end if
|
|
end procedure
|
|
|
|
rooted[1..2] = 1
|
|
unrooted[1..2] = 1
|
|
for n=1 to MAX_N do
|
|
tree(0, n)
|
|
bicenter(n)
|
|
if n<10 or n=MAX_N then
|
|
printf(1,"%d: %d\n",{n, unrooted[n+1]})
|
|
end if
|
|
end for
|