結果

問題 No.847 Divisors of Power
ユーザー ryusukeryusuke
提出日時 2022-08-10 22:58:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 975 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 81,872 KB
最終ジャッジ日時 2023-10-21 07:42:56
合計ジャッジ時間 5,716 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,740 KB
testcase_01 AC 35 ms
53,740 KB
testcase_02 AC 36 ms
53,740 KB
testcase_03 AC 35 ms
53,740 KB
testcase_04 AC 48 ms
64,576 KB
testcase_05 AC 36 ms
53,740 KB
testcase_06 AC 36 ms
57,440 KB
testcase_07 AC 37 ms
57,440 KB
testcase_08 AC 37 ms
57,440 KB
testcase_09 AC 38 ms
59,488 KB
testcase_10 AC 42 ms
62,076 KB
testcase_11 AC 51 ms
68,696 KB
testcase_12 AC 38 ms
59,488 KB
testcase_13 AC 47 ms
66,644 KB
testcase_14 AC 47 ms
64,524 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 #

# verification-helper: PROBLEM https://yukicoder.me/problems/no/847

import sys
sys.path.append("../../")

def factorization(n: int) -> int:
    arr, tmp = [], n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            arr.append([i, cnt])

    if tmp != 1:
        arr.append([tmp, 1])

    return arr

def dfs(a: list):
    global ans
    if len(a) == l:
        cnt = 1
        for i in range(len(a)):
            cnt *= fac[i][0] ** a[-1 - i]

        if cnt <= m:
            ans += 1
    
        return

    for i in range(num[l - len(a) - 1] + 1):
        dfs(a + [i])

n, k, m = map(int, input().split())

fac = factorization(n)
l = len(fac)

num = [-1] * l
for i in range(l):
    fac[i][1] *= k
    cnt = 0
    while fac[i][0] ** cnt <= m and cnt <= fac[i][1]:
        cnt += 1
    
    num[i] = cnt - 1

ans = 0
dfs([])
print(ans)
0