結果

問題 No.847 Divisors of Power
ユーザー AT274_
提出日時 2019-10-16 23:35:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-23 06:53:31
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
N, K, M = map(int, input().split())

prime_factors = []
for n in range(2, int(N ** 0.5) + 1):
    while N > 1:
        if N % n == 0:
            N //= n
            prime_factors.append(n)
        else:
            break
else:
    if N > 1:
        prime_factors.append(N)


C = Counter(prime_factors)
for c in C.keys():
    C[c] *= K
C = list(C.items())


def dfs(i, now):
    if i == len(C):
        return 1

    ans = 0
    for e in range(C[i][1] + 1):
        to_now = now * (C[i][0] ** e)
        if to_now > M:
            break
        ans += dfs(i + 1, to_now)
    return ans


print(dfs(0, 1))
0