結果

問題 No.1809 Divide NCK
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-14 21:39:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 59,556 KB
最終ジャッジ日時 2024-04-30 13:31:33
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,468 KB
testcase_01 AC 47 ms
58,188 KB
testcase_02 AC 32 ms
53,652 KB
testcase_03 AC 31 ms
53,548 KB
testcase_04 AC 32 ms
52,380 KB
testcase_05 AC 31 ms
54,088 KB
testcase_06 AC 32 ms
53,396 KB
testcase_07 AC 31 ms
52,612 KB
testcase_08 AC 32 ms
52,368 KB
testcase_09 AC 33 ms
53,140 KB
testcase_10 AC 33 ms
52,460 KB
testcase_11 AC 44 ms
58,172 KB
testcase_12 AC 47 ms
59,264 KB
testcase_13 AC 39 ms
59,268 KB
testcase_14 AC 40 ms
58,188 KB
testcase_15 AC 36 ms
59,304 KB
testcase_16 AC 46 ms
58,332 KB
testcase_17 AC 36 ms
58,748 KB
testcase_18 AC 53 ms
59,556 KB
testcase_19 AC 49 ms
58,880 KB
testcase_20 AC 45 ms
58,328 KB
testcase_21 AC 44 ms
57,376 KB
testcase_22 AC 34 ms
53,148 KB
testcase_23 AC 33 ms
52,256 KB
testcase_24 AC 33 ms
52,520 KB
testcase_25 AC 32 ms
52,980 KB
testcase_26 AC 32 ms
52,576 KB
testcase_27 AC 32 ms
52,444 KB
testcase_28 AC 30 ms
52,504 KB
testcase_29 AC 44 ms
58,280 KB
testcase_30 AC 46 ms
57,644 KB
testcase_31 AC 41 ms
58,616 KB
testcase_32 AC 43 ms
57,880 KB
testcase_33 AC 42 ms
58,460 KB
testcase_34 AC 43 ms
58,264 KB
testcase_35 AC 43 ms
58,616 KB
testcase_36 AC 41 ms
58,336 KB
testcase_37 AC 46 ms
58,804 KB
testcase_38 AC 42 ms
58,144 KB
testcase_39 AC 50 ms
58,120 KB
testcase_40 AC 49 ms
58,760 KB
testcase_41 AC 43 ms
58,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def factorize(n):
    d = {}
    temp = int(math.sqrt(n))+1
    for i in range(2, temp):
        while n%i== 0:
            n //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[n] = 1
    else:
        if n in d:
            d[n] += 1
        elif n != 1:
            d[n] =1
    return d

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

D = factorize(m)
ans = 10**18
for p, q in D.items():
    x = p
    cnt = 0
    while x <= n:
        cnt += n//x-(n-k)//x
        cnt -= k//x
        x *= p
    ans = min(ans, cnt//q)
print(ans)
0