結果

問題 No.847 Divisors of Power
ユーザー O2MTO2MT
提出日時 2020-12-07 23:58:00
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 879 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 848,332 KB
最終ジャッジ日時 2023-10-17 16:45:43
合計ジャッジ時間 3,069 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,800 KB
testcase_01 AC 48 ms
62,452 KB
testcase_02 RE -
testcase_03 AC 109 ms
266,044 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 44 ms
60,332 KB
testcase_07 MLE -
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
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 *
from copy import copy
def getDivisors(n: int):
    # validation check
    if not isinstance(n, int):
        raise("[ERROR] parameter must be integer")
    if n < 0:
        raise("[ERROR] parameter must be not less than 0 (n >= 0)")

    lowerDivisors, upperDivisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lowerDivisors.append(i)
            if i != n // i:
                upperDivisors.append(n//i)
        i += 1
    return lowerDivisors + upperDivisors[::-1]

N,K,M = map(int,input().split())
l = getDivisors(N)
hq = l.copy()
count = 0
M = min(N**K,M)
seen = [0]*(M+1)
while hq:
    q = heappop(hq)
    if q > M:
        break
    for i in l:
        num = q*i
        if num > M or (N**K)%num != 0 or seen[num] == 1:
            continue
        count += 1
        seen[num] = 1
        heappush(hq,num)
print(count)
0