結果

問題 No.847 Divisors of Power
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-11 14:08:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,484 KB
実行使用メモリ 15,532 KB
最終ジャッジ日時 2023-09-06 13:03:54
合計ジャッジ時間 4,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
15,160 KB
testcase_01 AC 92 ms
15,080 KB
testcase_02 AC 93 ms
15,076 KB
testcase_03 AC 92 ms
15,300 KB
testcase_04 AC 97 ms
15,416 KB
testcase_05 AC 94 ms
15,152 KB
testcase_06 AC 94 ms
15,068 KB
testcase_07 AC 96 ms
15,372 KB
testcase_08 AC 96 ms
15,160 KB
testcase_09 AC 92 ms
15,344 KB
testcase_10 AC 89 ms
15,304 KB
testcase_11 AC 88 ms
15,284 KB
testcase_12 AC 84 ms
15,068 KB
testcase_13 AC 87 ms
15,384 KB
testcase_14 AC 82 ms
15,420 KB
testcase_15 AC 239 ms
15,312 KB
testcase_16 AC 81 ms
15,344 KB
testcase_17 AC 84 ms
15,416 KB
testcase_18 AC 84 ms
15,388 KB
testcase_19 AC 86 ms
15,488 KB
testcase_20 AC 84 ms
15,344 KB
testcase_21 AC 138 ms
15,348 KB
testcase_22 AC 92 ms
15,308 KB
testcase_23 AC 88 ms
15,432 KB
testcase_24 AC 250 ms
15,532 KB
testcase_25 AC 81 ms
15,332 KB
testcase_26 AC 82 ms
15,348 KB
testcase_27 AC 83 ms
15,312 KB
testcase_28 AC 81 ms
15,176 KB
testcase_29 AC 88 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'
N, K, M = gets.split.map(&:to_i)
V = Prime.prime_division(N).map{|ne| ne.tap{ ne[1] *= K } }

def dfs(i, m)
  n = V[i][0]
  e = V[i][1]

  (0 .. e).inject(0) do |s, j|
    q = m * (n ** j)
    break s unless q <= M
    if i + 1 < V.size
      s + dfs(i + 1, q)
    else
      s + 1
    end
  end
end

puts N == 1 ? 1 : dfs(0, 1)
0