結果

問題 No.847 Divisors of Power
ユーザー MineMine
提出日時 2020-09-09 23:15:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 686 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 29,728 KB
最終ジャッジ日時 2023-08-22 14:09:45
合計ジャッジ時間 3,705 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,824 KB
testcase_01 AC 21 ms
8,792 KB
testcase_02 AC 22 ms
8,804 KB
testcase_03 AC 20 ms
8,956 KB
testcase_04 AC 20 ms
8,816 KB
testcase_05 AC 20 ms
8,908 KB
testcase_06 AC 21 ms
8,764 KB
testcase_07 AC 21 ms
8,796 KB
testcase_08 AC 22 ms
8,844 KB
testcase_09 AC 21 ms
8,800 KB
testcase_10 AC 21 ms
8,960 KB
testcase_11 AC 22 ms
9,036 KB
testcase_12 AC 21 ms
8,860 KB
testcase_13 AC 21 ms
8,824 KB
testcase_14 AC 21 ms
8,916 KB
testcase_15 AC 610 ms
29,728 KB
testcase_16 AC 21 ms
8,784 KB
testcase_17 AC 21 ms
8,860 KB
testcase_18 AC 23 ms
9,008 KB
testcase_19 AC 26 ms
9,364 KB
testcase_20 AC 18 ms
8,956 KB
testcase_21 AC 173 ms
14,304 KB
testcase_22 AC 19 ms
8,940 KB
testcase_23 AC 19 ms
8,792 KB
testcase_24 AC 686 ms
29,652 KB
testcase_25 AC 19 ms
8,788 KB
testcase_26 AC 17 ms
8,796 KB
testcase_27 AC 19 ms
8,884 KB
testcase_28 AC 18 ms
8,844 KB
testcase_29 AC 17 ms
8,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

def factorization(n):
    arr = defaultdict(int)
    for i in range(2, int(-(-n**0.5//1))+1):
        while n % i == 0:
            arr[i] += 1
            n //= i
    if n != 1:
        arr[n] += 1
    return arr

visited = defaultdict(bool)
def dfs(num, lst):
    for i in range(len(lst)):
        if num <= m:
            visited[num] = True
            if lst[i] < values[i] and not visited[num*keys[i]]:
                lst[i] += 1
                dfs(num*keys[i], lst)
                lst[i] -= 1
        else:
            return 0

n, k, m = map(int, input().split())
if n == 1:
    print(1)
    exit()
f = factorization(n)
keys = list(f.keys())
values = [v*k for v in f.values()]

dfs(1, [0]*len(keys))
print(sum(visited.values()))
0