A320509 とA320510
n が50以下のとき、出力してみた。
@ary1 = [1]
@ary2 = [1]
def partition(n, min, max)
return [[]] if n == 0
[max, n].min.downto(min).flat_map{|i| partition(n - i, min, i).map{|rest| [i, *rest]}}
end
# n > 0
def f(n)
cnt1, cnt2 = 0, 0
partition(n, 1, n).each{|ary|
ary << 0
ary0 = (1..ary.size - 1).map{|i| ary[i - 1] - ary[i]}
if ary0.sort == ary0
cnt1 += 1
cnt2 += 1 if ary0.uniq == ary0
end
}
@ary1 << cnt1
@ary2 << cnt2
end
n = 50
(1..n).each{|i| f(i)}
puts "A320509"
p @ary1
puts "A320510"
p @ary2
出力結果
A320509
[1, 1, 2, 3, 3, 4, 6, 4, 6, 8, 7, 8, 11, 7, 12, 14, 10, 13, 19, 12, 18, 21, 16, 19, 27, 19, 25, 30, 25, 30, 37, 25, 35, 40, 35, 42, 49, 35, 49, 56, 46, 54, 66, 50, 65, 72, 60, 70, 83, 68, 84]
A320510
[1, 1, 2, 1, 2, 2, 2, 2, 4, 2, 3, 4, 3, 4, 6, 3, 5, 6, 5, 6, 9, 5, 7, 9, 8, 8, 11, 8, 11, 13, 10, 12, 15, 11, 15, 16, 14, 16, 21, 15, 20, 22, 18, 21, 26, 21, 24, 28, 25, 28, 33]
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。