結果

問題 No.847 Divisors of Power
ユーザー roarisroaris
提出日時 2019-07-06 11:26:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-16 08:29:01
合計ジャッジ時間 2,442 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,624 KB
testcase_01 AC 33 ms
10,624 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 31 ms
10,496 KB
testcase_06 AC 33 ms
10,624 KB
testcase_07 AC 33 ms
10,624 KB
testcase_08 AC 34 ms
10,752 KB
testcase_09 AC 34 ms
10,752 KB
testcase_10 AC 32 ms
10,624 KB
testcase_11 AC 33 ms
10,624 KB
testcase_12 AC 34 ms
10,624 KB
testcase_13 AC 33 ms
10,624 KB
testcase_14 AC 33 ms
10,624 KB
testcase_15 AC 230 ms
10,624 KB
testcase_16 AC 34 ms
10,624 KB
testcase_17 AC 35 ms
10,880 KB
testcase_18 AC 34 ms
10,624 KB
testcase_19 AC 38 ms
10,624 KB
testcase_20 AC 32 ms
10,752 KB
testcase_21 AC 92 ms
10,624 KB
testcase_22 AC 33 ms
10,624 KB
testcase_23 AC 34 ms
10,752 KB
testcase_24 AC 251 ms
10,752 KB
testcase_25 AC 33 ms
10,752 KB
testcase_26 AC 31 ms
10,496 KB
testcase_27 AC 34 ms
10,752 KB
testcase_28 AC 30 ms
10,624 KB
testcase_29 AC 31 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(depth, cur):
    if depth == len(K_factors):
        return 1
        
    num, exp = K_factors[depth]
    
    for i in range(exp+1):
        if cur * num ** i > M:
            mark = i
            break
    else:
        mark = exp + 1

    return sum([dfs(depth+1, cur * num ** m) for m in range(mark)])
    
def factorize(n):
    factors = []
    
    for div in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while n % div == 0:
            n //= div
            cnt += 1
        if cnt >= 1:
            factors.append((div, cnt))
            
    if n > 1:
        factors.append((n, 1))
        
    return factors

N, K, M = map(int, input().split())
factors = factorize(N)
K_factors = []

for factor, cnt in factors:
    K_factors.append((factor, cnt * K))

print(dfs(0, 1))
0