結果
| 問題 | 
                            No.847 Divisors of Power
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-12-07 23:58:00 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 879 bytes | 
| コンパイル時間 | 161 ms | 
| コンパイル使用メモリ | 82,340 KB | 
| 実行使用メモリ | 847,864 KB | 
| 最終ジャッジ日時 | 2024-09-17 14:09:40 | 
| 合計ジャッジ時間 | 2,987 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 4 | 
| other | AC * 4 RE * 3 MLE * 2 -- * 17 | 
ソースコード
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)