結果
問題 | No.847 Divisors of Power |
ユーザー | ikd |
提出日時 | 2019-07-05 22:30:37 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 343 ms / 2,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 22,400 KB |
最終ジャッジ日時 | 2024-10-06 22:28:15 |
合計ジャッジ時間 | 4,034 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
コンパイルメッセージ
Syntax OK
ソースコード
$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