結果

問題 No.847 Divisors of Power
ユーザー toyuzukotoyuzuko
提出日時 2020-04-17 22:18:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 509 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 25,192 KB
最終ジャッジ日時 2024-04-14 14:33:17
合計ジャッジ時間 3,221 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 31 ms
10,752 KB
testcase_12 AC 31 ms
10,880 KB
testcase_13 AC 30 ms
10,880 KB
testcase_14 AC 30 ms
10,880 KB
testcase_15 AC 411 ms
24,716 KB
testcase_16 AC 30 ms
10,752 KB
testcase_17 AC 30 ms
10,880 KB
testcase_18 AC 30 ms
10,880 KB
testcase_19 AC 33 ms
11,008 KB
testcase_20 AC 31 ms
10,880 KB
testcase_21 AC 130 ms
13,912 KB
testcase_22 AC 32 ms
10,752 KB
testcase_23 AC 34 ms
10,752 KB
testcase_24 AC 509 ms
25,192 KB
testcase_25 AC 31 ms
10,880 KB
testcase_26 AC 30 ms
10,880 KB
testcase_27 AC 34 ms
10,752 KB
testcase_28 AC 30 ms
10,752 KB
testcase_29 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter, defaultdict

def factorization(n):
    if n == 1: return [1]
    res = []
    x = n
    y = 2
    while y * y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1: res.append(x)
    return res

N, K, M = map(int, input().split())

if N == 1:
    print(1)

else:
    F = Counter(factorization(N))
    D = defaultdict(int)

    for x, k in F.items():
        for i in range(k * K + 1):
            if x**i > M:
                D[x] = i - 1
                break
        else:
            D[x] = k * K

    dp = defaultdict(int)
    dp[1] = True

    for x, k in D.items():
        tmp = set()
        for i in range(k):
            for j in dp.keys():
                if j * (x**(i + 1)) <= M:
                    tmp.add(j * (x**(i + 1)))
        for x in tmp:
            dp[x] = True

    print(len(dp))
0