結果

問題 No.1973 Divisor Sequence
ユーザー TKG1TKG1
提出日時 2022-06-11 00:29:26
言語 Crystal
(1.11.2)
結果
AC  
実行時間 399 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 14,887 ms
コンパイル使用メモリ 290,392 KB
実行使用メモリ 204,444 KB
最終ジャッジ日時 2023-10-21 06:30:35
合計ジャッジ時間 17,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 186 ms
61,124 KB
testcase_03 AC 14 ms
8,028 KB
testcase_04 AC 91 ms
28,328 KB
testcase_05 AC 40 ms
22,024 KB
testcase_06 AC 103 ms
38,108 KB
testcase_07 AC 25 ms
10,728 KB
testcase_08 AC 57 ms
22,224 KB
testcase_09 AC 80 ms
25,260 KB
testcase_10 AC 101 ms
30,516 KB
testcase_11 AC 18 ms
7,880 KB
testcase_12 AC 83 ms
31,484 KB
testcase_13 AC 29 ms
13,024 KB
testcase_14 AC 69 ms
24,580 KB
testcase_15 AC 132 ms
32,940 KB
testcase_16 AC 128 ms
38,884 KB
testcase_17 AC 85 ms
26,172 KB
testcase_18 AC 8 ms
4,484 KB
testcase_19 AC 110 ms
33,108 KB
testcase_20 AC 24 ms
9,204 KB
testcase_21 AC 153 ms
61,604 KB
testcase_22 AC 110 ms
33,136 KB
testcase_23 AC 399 ms
204,444 KB
testcase_24 AC 355 ms
61,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

alias LL = Int64
macro chmin(x, y); {{x}} = {{y}} if {{x}} > {{y}}; end
macro chmax(x, y); {{x}} = {{y}} if {{x}} < {{y}}; end
macro yn(x); {{x}} ? "Yes" : "No"; end

# 素因数分解
def factorization(n : Int64)
  res = [] of Array(Int64)
  i = 2i64
  while i * i <= n
    if n % i == 0
      cnt = 0i64
      while n % i == 0
        n //= i
        cnt += 1
      end
      res << [i, cnt]
    end
    i += 1
  end
  res << [n, 1i64] if n != 1
  return res
end

# ---------------------------------------------------- :)

n, m = read_line.split.map(&.to_i64)
mod = 10**9+7
pr = factorization(m)
ans = 1i64

pr.size.times do |i|
  e = pr[i][-1]
  dp = Array.new(n+1){Array.new(e+1, 0i64)}
  0.upto(e) do |i|
    dp[0][i] = 1
  end

  0.upto(n-1) do |j|
    s = 0i64
    e.downto(0) do |k|
      s += dp[j][e-k]
      s %= mod
      dp[j+1][k] = s
    end
  end

  ans = (ans * dp[n-1].sum(&.% mod)) % mod
end

puts ans
0