結果

問題 No.847 Divisors of Power
ユーザー neko_the_shadow
提出日時 2019-07-14 23:36:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 498 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 178,632 KB
最終ジャッジ日時 2024-10-07 02:01:03
合計ジャッジ時間 3,961 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import math, collections, functools

n, k, m = map(int, input().split())

d = collections.defaultdict(int)
for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
        d[i] += 1
        n //= i
if n > 1:
    d[n] += 1

p = list(sorted(d.keys())) # 素数
q = [d[i] * k for i in p]      # 指数

# x: 添え字
# y: 合計
@functools.lru_cache(maxsize=None)
def f(x, y):
    if x == len(p):
        return 1
    
    t = 0
    z = 1
    for i in range(q[x] + 1):
        z = y * (p[x] ** i)
        if m < z:
            break
        t += f(x + 1, z)
    return t

print(f(0, 1))
0