結果

問題 No.847 Divisors of Power
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-11 14:05:11
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 331 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 11,340 KB
実行使用メモリ 15,668 KB
最終ジャッジ日時 2023-09-06 13:03:47
合計ジャッジ時間 5,637 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,156 KB
testcase_01 AC 89 ms
15,308 KB
testcase_02 AC 93 ms
15,108 KB
testcase_03 AC 94 ms
15,244 KB
testcase_04 AC 93 ms
15,108 KB
testcase_05 AC 93 ms
15,344 KB
testcase_06 AC 93 ms
15,152 KB
testcase_07 AC 94 ms
15,296 KB
testcase_08 AC 95 ms
15,376 KB
testcase_09 AC 95 ms
15,316 KB
testcase_10 AC 97 ms
15,204 KB
testcase_11 AC 95 ms
15,244 KB
testcase_12 AC 91 ms
15,200 KB
testcase_13 AC 90 ms
15,316 KB
testcase_14 AC 87 ms
15,320 KB
testcase_15 AC 247 ms
15,376 KB
testcase_16 AC 89 ms
15,236 KB
testcase_17 AC 85 ms
15,324 KB
testcase_18 AC 84 ms
15,308 KB
testcase_19 AC 87 ms
15,272 KB
testcase_20 AC 84 ms
15,156 KB
testcase_21 AC 129 ms
15,540 KB
testcase_22 AC 85 ms
15,256 KB
testcase_23 AC 88 ms
15,260 KB
testcase_24 AC 252 ms
15,356 KB
testcase_25 AC 80 ms
15,344 KB
testcase_26 AC 79 ms
15,228 KB
testcase_27 AC 85 ms
15,540 KB
testcase_28 AC 83 ms
15,292 KB
testcase_29 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 dfs(0, 1)
0