結果

問題 No.847 Divisors of Power
ユーザー ikdikd
提出日時 2019-07-05 22:30:37
言語 Ruby
(3.2.2)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 24,912 KB
最終ジャッジ日時 2023-07-28 23:52:13
合計ジャッジ時間 5,128 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,288 KB
testcase_01 AC 86 ms
15,288 KB
testcase_02 AC 86 ms
15,264 KB
testcase_03 AC 88 ms
15,320 KB
testcase_04 AC 89 ms
15,316 KB
testcase_05 AC 87 ms
15,096 KB
testcase_06 AC 88 ms
15,296 KB
testcase_07 AC 88 ms
15,156 KB
testcase_08 AC 90 ms
15,076 KB
testcase_09 AC 88 ms
15,272 KB
testcase_10 AC 88 ms
15,144 KB
testcase_11 AC 88 ms
15,048 KB
testcase_12 AC 89 ms
15,384 KB
testcase_13 AC 88 ms
15,280 KB
testcase_14 AC 87 ms
15,092 KB
testcase_15 AC 317 ms
20,372 KB
testcase_16 AC 86 ms
15,180 KB
testcase_17 AC 86 ms
15,164 KB
testcase_18 AC 87 ms
15,328 KB
testcase_19 AC 89 ms
15,324 KB
testcase_20 AC 87 ms
15,184 KB
testcase_21 AC 155 ms
17,948 KB
testcase_22 AC 89 ms
15,324 KB
testcase_23 AC 89 ms
15,108 KB
testcase_24 AC 366 ms
24,912 KB
testcase_25 AC 87 ms
15,128 KB
testcase_26 AC 87 ms
15,328 KB
testcase_27 AC 89 ms
15,328 KB
testcase_28 AC 86 ms
15,048 KB
testcase_29 AC 86 ms
15,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$N, $K, $M = gets.split.map(&:to_i)
$factors = []
n = $N
i = 2
while i * i <= n and n > 0
  cnt = 0
  while n % i == 0
    n = n / i
    cnt += 1
  end
  if cnt > 0
    $factors.push([i, cnt * $K])
  end
  i += 1
end
if n > 1
  $factors.push([n, 1 * $K])
end
require "set"
$seen = Set.new

def dfs(i, val)
  if val > $M
    return
  end
  $seen.add(val)
  if i >= $factors.size
    return
  end
  dfs(i + 1, val)
  f = $factors[i]
  p = f[0]
  f[1].times do
    dfs(i + 1, val * p)
    p *= f[0]
    if p > $M
      break
    end
  end
end

dfs(0, 1)
puts $seen.size
0