結果

問題 No.847 Divisors of Power
ユーザー lloyzlloyz
提出日時 2022-06-04 12:33:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 81,708 KB
実行使用メモリ 105,944 KB
最終ジャッジ日時 2023-10-21 02:38:21
合計ジャッジ時間 4,244 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,492 KB
testcase_01 AC 36 ms
55,540 KB
testcase_02 AC 36 ms
55,540 KB
testcase_03 AC 39 ms
55,540 KB
testcase_04 AC 43 ms
55,540 KB
testcase_05 AC 38 ms
55,540 KB
testcase_06 AC 44 ms
59,544 KB
testcase_07 AC 38 ms
55,540 KB
testcase_08 AC 41 ms
59,608 KB
testcase_09 AC 38 ms
55,540 KB
testcase_10 AC 39 ms
55,540 KB
testcase_11 AC 40 ms
55,540 KB
testcase_12 AC 39 ms
55,540 KB
testcase_13 AC 40 ms
55,540 KB
testcase_14 AC 38 ms
55,540 KB
testcase_15 AC 92 ms
105,144 KB
testcase_16 AC 44 ms
59,612 KB
testcase_17 AC 38 ms
55,540 KB
testcase_18 AC 38 ms
55,540 KB
testcase_19 AC 44 ms
64,040 KB
testcase_20 AC 43 ms
59,548 KB
testcase_21 AC 61 ms
78,544 KB
testcase_22 AC 42 ms
59,548 KB
testcase_23 AC 40 ms
59,548 KB
testcase_24 AC 94 ms
105,944 KB
testcase_25 AC 38 ms
55,540 KB
testcase_26 AC 36 ms
53,496 KB
testcase_27 AC 41 ms
59,548 KB
testcase_28 AC 38 ms
55,540 KB
testcase_29 AC 36 ms
53,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

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

prime_counter = defaultdict(int)
c = 0
while n % 2 == 0:
    c += 1
    n //= 2
if c > 0:
    prime_counter[2] = c * k
f = 3
while f * f <= n:
    c = 0
    while n % f == 0:
        c += 1
        n //= f
    if c > 0:
        prime_counter[f] = c * k
    f += 2
if n != 1:
    prime_counter[n] += k

DP = set()
DP.add(1)
for prime, cnt in prime_counter.items():
    NDP = set()
    for d in DP:
        NDP.add(d)
        nd = d
        for i in range(cnt):
            nd *= prime
            if nd <= m:
                NDP.add(nd)
            else:
                break
    DP = NDP
print(len(DP))
0