結果

問題 No.847 Divisors of Power
ユーザー ryusukeryusuke
提出日時 2022-08-10 23:00:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,069 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 66,568 KB
最終ジャッジ日時 2023-10-21 07:44:02
合計ジャッジ時間 4,836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,744 KB
testcase_01 AC 36 ms
53,744 KB
testcase_02 AC 35 ms
53,744 KB
testcase_03 AC 34 ms
53,744 KB
testcase_04 AC 44 ms
64,420 KB
testcase_05 AC 34 ms
53,744 KB
testcase_06 AC 37 ms
57,444 KB
testcase_07 AC 36 ms
57,444 KB
testcase_08 AC 39 ms
57,444 KB
testcase_09 AC 37 ms
59,492 KB
testcase_10 AC 40 ms
59,888 KB
testcase_11 AC 49 ms
66,568 KB
testcase_12 AC 37 ms
59,492 KB
testcase_13 AC 50 ms
66,564 KB
testcase_14 AC 50 ms
64,440 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
        check = True
        for i in range(len(a)):
            cnt *= fac[i][0] ** a[-1 - i]
            if cnt > m:
                check = False
                break

        if check:
            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