結果

問題 No.1581 Multiple Sequence
ユーザー simansiman
提出日時 2022-06-26 13:07:39
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 496 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 14,336 KB
最終ジャッジ日時 2024-04-28 05:25:44
合計ジャッジ時間 27,721 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,288 KB
testcase_01 AC 75 ms
12,288 KB
testcase_02 AC 1,651 ms
13,952 KB
testcase_03 AC 1,829 ms
14,208 KB
testcase_04 AC 588 ms
13,568 KB
testcase_05 AC 1,848 ms
14,336 KB
testcase_06 AC 914 ms
13,824 KB
testcase_07 AC 571 ms
13,696 KB
testcase_08 AC 715 ms
13,440 KB
testcase_09 AC 1,757 ms
14,080 KB
testcase_10 AC 1,172 ms
13,824 KB
testcase_11 AC 333 ms
13,440 KB
testcase_12 AC 785 ms
13,824 KB
testcase_13 AC 121 ms
12,800 KB
testcase_14 AC 1,798 ms
14,208 KB
testcase_15 AC 1,326 ms
13,824 KB
testcase_16 AC 391 ms
13,568 KB
testcase_17 AC 1,962 ms
14,336 KB
testcase_18 AC 285 ms
13,696 KB
testcase_19 AC 1,582 ms
13,824 KB
testcase_20 AC 1,651 ms
14,080 KB
testcase_21 AC 1,767 ms
13,952 KB
testcase_22 AC 1,096 ms
13,824 KB
testcase_23 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }
  end
end

M = gets.to_i
MOD = 10 ** 9 + 7
dp = Array.new(M + 1, 0)
dp[0] = 1
dp[1] = 1

2.upto(M) do |i|
  i.divisor_list.each do |j|
    dp[i] += dp[i / j - 1]
    dp[i] %= MOD
  end
end

puts dp[M]
0