結果

問題 No.847 Divisors of Power
ユーザー tpynerivertpyneriver
提出日時 2019-08-10 20:48:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,267 ms / 2,000 ms
コード長 879 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 125,312 KB
最終ジャッジ日時 2024-04-16 10:19:32
合計ジャッジ時間 5,378 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,736 KB
testcase_01 AC 43 ms
53,504 KB
testcase_02 AC 55 ms
63,104 KB
testcase_03 AC 43 ms
53,504 KB
testcase_04 AC 69 ms
69,888 KB
testcase_05 AC 48 ms
59,008 KB
testcase_06 AC 46 ms
58,284 KB
testcase_07 AC 45 ms
58,240 KB
testcase_08 AC 45 ms
57,984 KB
testcase_09 AC 59 ms
63,872 KB
testcase_10 AC 61 ms
65,024 KB
testcase_11 AC 78 ms
73,856 KB
testcase_12 AC 47 ms
58,624 KB
testcase_13 AC 84 ms
76,800 KB
testcase_14 AC 69 ms
67,928 KB
testcase_15 AC 1,035 ms
115,800 KB
testcase_16 AC 45 ms
58,112 KB
testcase_17 AC 48 ms
59,520 KB
testcase_18 AC 83 ms
76,672 KB
testcase_19 AC 96 ms
76,948 KB
testcase_20 AC 46 ms
58,368 KB
testcase_21 AC 349 ms
88,192 KB
testcase_22 AC 46 ms
58,368 KB
testcase_23 AC 47 ms
58,112 KB
testcase_24 AC 1,267 ms
125,312 KB
testcase_25 AC 51 ms
60,416 KB
testcase_26 AC 43 ms
53,120 KB
testcase_27 AC 46 ms
57,728 KB
testcase_28 AC 45 ms
53,632 KB
testcase_29 AC 44 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush as hp, heappop as hpp
def prf(m):
    pf = {}
    for i in range(2, int(m**0.5)+1):
        while m % i == 0:
            pf[i] = pf.get(i, 0)+1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf

def calc(Num, L):
    res = 1
    for n, l in zip(Num, L):
        res *= pow(l, n)
    return res

N, K, M = map(int, input().split())
Pf = prf(N)
if not Pf:
    print(1)
else:
    Pkey, Pval = map(list, zip(*Pf.items()))
    pl = len(Pkey)
    
    cnt = 0
    Q = [(1, tuple(0 for _ in range(pl)))]
    used = set()
    while Q:
        x, pp = Q.pop()
        if x > M or any(a*K < b for a, b in zip(Pval, pp)) or pp in used:
            continue
        used.add(pp)
        cnt += 1
        for i in range(pl):
            lp = list(pp)
            lp[i] += 1
            Q.append((calc(lp, Pkey), tuple(lp)))
    
    print(cnt)     
0