結果

問題 No.847 Divisors of Power
ユーザー kekurekekure
提出日時 2019-07-08 12:51:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 76,736 KB
最終ジャッジ日時 2024-04-16 09:13:44
合計ジャッジ時間 2,669 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 39 ms
52,224 KB
testcase_02 AC 39 ms
52,140 KB
testcase_03 AC 39 ms
52,224 KB
testcase_04 AC 40 ms
52,352 KB
testcase_05 AC 39 ms
52,204 KB
testcase_06 AC 41 ms
57,728 KB
testcase_07 AC 39 ms
52,224 KB
testcase_08 AC 45 ms
57,380 KB
testcase_09 AC 42 ms
57,728 KB
testcase_10 AC 40 ms
52,608 KB
testcase_11 AC 41 ms
53,120 KB
testcase_12 AC 42 ms
57,344 KB
testcase_13 AC 44 ms
58,880 KB
testcase_14 AC 40 ms
52,736 KB
testcase_15 AC 122 ms
76,416 KB
testcase_16 AC 42 ms
57,600 KB
testcase_17 AC 42 ms
57,472 KB
testcase_18 AC 47 ms
60,416 KB
testcase_19 AC 60 ms
68,992 KB
testcase_20 AC 42 ms
57,728 KB
testcase_21 AC 114 ms
76,736 KB
testcase_22 AC 42 ms
57,728 KB
testcase_23 AC 42 ms
57,344 KB
testcase_24 AC 122 ms
76,192 KB
testcase_25 AC 40 ms
52,096 KB
testcase_26 AC 39 ms
52,480 KB
testcase_27 AC 42 ms
57,344 KB
testcase_28 AC 38 ms
52,608 KB
testcase_29 AC 39 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factoring(n):
    i = 2
    fact = []
    while True:
        if n < i * i:
            break
        if n % i == 0:
            fact.append(i)
            n //= i
        else:
            i += 1
    fact.append(n)
    t = fact[0]
    fact_converted = []
    cnt = 0
    for x in fact:
        if t == x:
            cnt += 1
        else:
            fact_converted.append([t, cnt])
            t = x
            cnt = 1
    fact_converted.append([t, cnt])

    return fact_converted


def count(mass, fact, k, M, leng):
    if mass > M:
        return 0
    if k == leng:
        return 1
    cnt = 0
    for i in range(fact[k][1] + 1):
        sum = count(mass * (fact[k][0] ** i), fact, k + 1, M, leng)
        if sum == 0:
            break
        else:
            cnt += sum
    return cnt


N, K, M = map(int, input().split())
if N == 1:
    print('1')
else:
    fact = [[x[0], x[1] * K] for x in factoring(N)]
    leng = len(fact)
    print(count(1, fact, 0, M, leng))




0