結果

問題 No.847 Divisors of Power
ユーザー tpynerivertpyneriver
提出日時 2019-08-10 20:45:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 909 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,276 KB
最終ジャッジ日時 2024-04-16 10:18:13
合計ジャッジ時間 4,942 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
58,368 KB
testcase_01 AC 45 ms
54,852 KB
testcase_02 AC 69 ms
65,920 KB
testcase_03 AC 45 ms
53,120 KB
testcase_04 AC 85 ms
73,344 KB
testcase_05 AC 57 ms
61,568 KB
testcase_06 AC 48 ms
57,728 KB
testcase_07 AC 48 ms
58,624 KB
testcase_08 AC 49 ms
58,240 KB
testcase_09 AC 71 ms
67,072 KB
testcase_10 AC 72 ms
68,224 KB
testcase_11 AC 108 ms
77,120 KB
testcase_12 AC 49 ms
59,264 KB
testcase_13 AC 116 ms
77,276 KB
testcase_14 AC 83 ms
72,960 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

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 = hpp(Q)
        if x > M:
            break
        if 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
            hp(Q, (calc(lp, Pkey), tuple(lp)))
    
    print(cnt)           
0