Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
62
Task/Paraffins/Seed7/paraffins.seed7
Normal file
62
Task/Paraffins/Seed7/paraffins.seed7
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "bigint.s7i";
|
||||
|
||||
const integer: max_n is 500;
|
||||
const integer: branch is 4;
|
||||
|
||||
var array bigInteger: rooted is max_n times 0_;
|
||||
var array bigInteger: unrooted is max_n times 0_;
|
||||
|
||||
const proc: tree (in integer: br, in integer: n, in integer: l, in var integer: sum, in bigInteger: cnt) is func
|
||||
local
|
||||
var integer: b is 0;
|
||||
var integer: m is 0;
|
||||
var bigInteger: c is 0_;
|
||||
var bigInteger: diff is 0_;
|
||||
begin
|
||||
for b range br + 1 to branch do
|
||||
sum +:= n;
|
||||
if sum > max_n or l * 2 >= sum and b >= branch then
|
||||
# Prevent unneeded long math.
|
||||
b := branch;
|
||||
else
|
||||
if b = (br + 1) then
|
||||
c := rooted[n] * cnt;
|
||||
else
|
||||
diff := bigInteger conv (b - br);
|
||||
c := c * (rooted[n] + pred(diff)) div diff;
|
||||
end if;
|
||||
if l * 2 < sum then
|
||||
unrooted[sum] +:= c;
|
||||
end if;
|
||||
if b < branch then
|
||||
rooted[sum] +:= c;
|
||||
for m range n-1 downto 1 do
|
||||
tree(b, m, l, sum, c);
|
||||
end for;
|
||||
end if;
|
||||
end if;
|
||||
end for;
|
||||
end func;
|
||||
|
||||
const proc: bicenter (in integer: s) is func
|
||||
begin
|
||||
if not odd(s) then
|
||||
unrooted[s] +:= (rooted[s div 2] * succ(rooted[s div 2])) >> 1;
|
||||
end if;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var bigInteger: cnt is 1_;
|
||||
var integer: n is 0;
|
||||
var integer: sum is 1;
|
||||
begin
|
||||
rooted[1] := 1_;
|
||||
unrooted[1] := 1_;
|
||||
for n range 1 to max_n do
|
||||
tree(0, n, n, sum, cnt);
|
||||
bicenter(n);
|
||||
writeln(n <& ": " <& unrooted[n]);
|
||||
end for;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue