2018年3月11日日曜日

180311

Ruby


A053633

面白そうだったので、出力してみた。

# m次以下を取り出す
def mul(f_ary, b_ary, m)
  s1, s2 = f_ary.size, b_ary.size
  ary = Array.new(s1 + s2 - 1, 0)
  (0..s1 - 1).each{|i|
    (0..s2 - 1).each{|j|
      ary[i + j] += f_ary[i] * b_ary[j]
    }
  }
  ary[0..m]
end

def A(n)
  p [0, ary = [1]]
  (1..n).each{|i|
    b_ary = Array.new(i + 1, 0)
    b_ary[0], b_ary[-1] = 1, 1
    ary = mul(ary, b_ary, i * (i + 1) / 2)
    ary0 = []
    (0..i).each{|j|
      ary0 << j.step(ary.size - 1, i + 1).inject(0){|s, k| s + ary[k]}
    }
    p [i, ary0]
  }
end

A(50)

出力結果
[0, [1]]
[1, [1, 1]]
[2, [2, 1, 1]]
[3, [2, 2, 2, 2]]
[4, [4, 3, 3, 3, 3]]
[5, [6, 5, 5, 6, 5, 5]]
[6, [10, 9, 9, 9, 9, 9, 9]]
[7, [16, 16, 16, 16, 16, 16, 16, 16]]
[8, [30, 28, 28, 29, 28, 28, 29, 28, 28]]
[9, [52, 51, 51, 51, 51, 52, 51, 51, 51, 51]]
[10, [94, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93]]
[11, [172, 170, 170, 172, 170, 170, 172, 170, 170, 172, 170, 170]]
[12, [316, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315]]
[13, [586, 585, 585, 585, 585, 585, 585, 586, 585, 585, 585, 585, 585, 585]]
[14, [1096, 1091, 1091, 1094, 1091, 1092, 1094, 1091, 1091, 1094, 1092, 1091, 1094, 1091, 1091]]
[15, [2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048]]
[16, [3856, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855, 3855]]
[17, [7286, 7280, 7280, 7285, 7280, 7280, 7285, 7280, 7280, 7286, 7280, 7280, 7285, 7280, 7280, 7285, 7280, 7280]]
[18, [13798, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797, 13797]]
[19, [26216, 26214, 26214, 26214, 26214, 26216, 26214, 26214, 26214, 26214, 26216, 26214, 26214, 26214, 26214, 26216, 26214, 26214, 26214, 26214]]
[20, [49940, 49929, 49929, 49938, 49929, 49929, 49938, 49930, 49929, 49938, 49929, 49929, 49938, 49929, 49930, 49938, 49929, 49929, 49938, 49929, 49929]]
[21, [95326, 95325, 95325, 95325, 95325, 95325, 95325, 95325, 95325, 95325, 95325, 95326, 95325, 95325, 95325, 95325, 95325, 95325, 95325, 95325, 95325, 95325]]
[22, [182362, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361, 182361]]
[23, [349536, 349520, 349520, 349536, 349520, 349520, 349536, 349520, 349520, 349536, 349520, 349520, 349536, 349520, 349520, 349536, 349520, 349520, 349536, 349520, 349520, 349536, 349520, 349520]]
[24, [671092, 671088, 671088, 671088, 671088, 671091, 671088, 671088, 671088, 671088, 671091, 671088, 671088, 671088, 671088, 671091, 671088, 671088, 671088, 671088, 671091, 671088, 671088, 671088, 671088]]
[25, [1290556, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290556, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555, 1290555]]
[26, [2485534, 2485504, 2485504, 2485532, 2485504, 2485504, 2485532, 2485504, 2485504, 2485533, 2485504, 2485504, 2485532, 2485504, 2485504, 2485532, 2485504, 2485504, 2485533, 2485504, 2485504, 2485532, 2485504, 2485504, 2485532, 2485504, 2485504]]
[27, [4793492, 4793490, 4793490, 4793490, 4793490, 4793490, 4793490, 4793492, 4793490, 4793490, 4793490, 4793490, 4793490, 4793490, 4793492, 4793490, 4793490, 4793490, 4793490, 4793490, 4793490, 4793492, 4793490, 4793490, 4793490, 4793490, 4793490, 4793490]]
[28, [9256396, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395, 9256395]]
[29, [17895736, 17895679, 17895679, 17895730, 17895679, 17895684, 17895730, 17895679, 17895679, 17895730, 17895684, 17895679, 17895730, 17895679, 17895679, 17895736, 17895679, 17895679, 17895730, 17895679, 17895684, 17895730, 17895679, 17895679, 17895730, 17895684, 17895679, 17895730, 17895679, 17895679]]
[30, [34636834, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833, 34636833]]
[31, [67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864, 67108864]]
[32, [130150588, 130150493, 130150493, 130150586, 130150493, 130150493, 130150586, 130150493, 130150493, 130150586, 130150493, 130150494, 130150586, 130150493, 130150493, 130150586, 130150493, 130150493, 130150586, 130150493, 130150493, 130150586, 130150494, 130150493, 130150586, 130150493, 130150493, 130150586, 130150493, 130150493, 130150586, 130150493, 130150493]]
[33, [252645136, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645136, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135, 252645135]]
[34, [490853416, 490853403, 490853403, 490853403, 490853403, 490853412, 490853403, 490853406, 490853403, 490853403, 490853412, 490853403, 490853403, 490853403, 490853406, 490853412, 490853403, 490853403, 490853403, 490853403, 490853412, 490853406, 490853403, 490853403, 490853403, 490853412, 490853403, 490853403, 490853406, 490853403, 490853412, 490853403, 490853403, 490853403, 490853403]]
[35, [954437292, 954437120, 954437120, 954437290, 954437120, 954437120, 954437290, 954437120, 954437120, 954437292, 954437120, 954437120, 954437290, 954437120, 954437120, 954437290, 954437120, 954437120, 954437292, 954437120, 954437120, 954437290, 954437120, 954437120, 954437290, 954437120, 954437120, 954437292, 954437120, 954437120, 954437290, 954437120, 954437120, 954437290, 954437120, 954437120]]
[36, [1857283156, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155, 1857283155]]
[37, [3616814566, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814566, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565, 3616814565]]
[38, [7048151672, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151356, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151356, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355, 7048151670, 7048151355, 7048151355]]
[39, [13743895360, 13743895344, 13743895344, 13743895344, 13743895344, 13743895360, 13743895344, 13743895344, 13743895344, 13743895344, 13743895360, 13743895344, 13743895344, 13743895344, 13743895344, 13743895360, 13743895344, 13743895344, 13743895344, 13743895344, 13743895360, 13743895344, 13743895344, 13743895344, 13743895344, 13743895360, 13743895344, 13743895344, 13743895344, 13743895344, 13743895360, 13743895344, 13743895344, 13743895344, 13743895344, 13743895360, 13743895344, 13743895344, 13743895344, 13743895344]]
[40, [26817356776, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775, 26817356775]]
[41, [52357696956, 52357696365, 52357696365, 52357696950, 52357696365, 52357696365, 52357696950, 52357696370, 52357696365, 52357696950, 52357696365, 52357696365, 52357696950, 52357696365, 52357696370, 52357696950, 52357696365, 52357696365, 52357696950, 52357696365, 52357696365, 52357696956, 52357696365, 52357696365, 52357696950, 52357696365, 52357696365, 52357696950, 52357696370, 52357696365, 52357696950, 52357696365, 52357696365, 52357696950, 52357696365, 52357696370, 52357696950, 52357696365, 52357696365, 52357696950, 52357696365, 52357696365]]
[42, [102280151422, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421, 102280151421]]
[43, [199911205052, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205052, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205052, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205052, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050, 199911205050]]
[44, [390937468408, 390937467284, 390937467284, 390937468375, 390937467284, 390937467312, 390937468375, 390937467284, 390937467284, 390937468378, 390937467312, 390937467284, 390937468375, 390937467284, 390937467284, 390937468404, 390937467284, 390937467284, 390937468378, 390937467284, 390937467312, 390937468375, 390937467284, 390937467284, 390937468375, 390937467312, 390937467284, 390937468378, 390937467284, 390937467284, 390937468404, 390937467284, 390937467284, 390937468375, 390937467284, 390937467312, 390937468378, 390937467284, 390937467284, 390937468375, 390937467312, 390937467284, 390937468375, 390937467284, 390937467284]]
[45, [764877654106, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654106, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105, 764877654105]]
[46, [1497207322930, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929, 1497207322929]]
[47, [2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720, 2932031008768, 2932031006720, 2932031006720]]
[48, [5744387279818, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279817, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279817, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279817, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279817, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279817, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279817, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808, 5744387279808]]
[49, [11258999068468, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068468, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416, 11258999068467, 11258999068416, 11258999068416, 11258999068416, 11258999068416]]
[50, [22076468764192, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760336, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760336, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335, 22076468764190, 22076468760335, 22076468760335]]

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。