結果

問題 No.1809 Divide NCK
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-14 21:39:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 75,668 KB
最終ジャッジ日時 2023-08-12 18:25:34
合計ジャッジ時間 5,155 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,292 KB
testcase_01 AC 89 ms
75,368 KB
testcase_02 AC 73 ms
71,372 KB
testcase_03 AC 71 ms
71,664 KB
testcase_04 AC 71 ms
71,668 KB
testcase_05 AC 72 ms
71,612 KB
testcase_06 AC 70 ms
71,600 KB
testcase_07 AC 72 ms
71,648 KB
testcase_08 AC 72 ms
71,164 KB
testcase_09 AC 73 ms
71,448 KB
testcase_10 AC 72 ms
71,332 KB
testcase_11 AC 88 ms
75,340 KB
testcase_12 AC 90 ms
75,340 KB
testcase_13 AC 77 ms
75,460 KB
testcase_14 AC 80 ms
75,344 KB
testcase_15 AC 74 ms
75,132 KB
testcase_16 AC 89 ms
75,368 KB
testcase_17 AC 76 ms
75,528 KB
testcase_18 AC 88 ms
75,536 KB
testcase_19 AC 89 ms
75,540 KB
testcase_20 AC 86 ms
75,472 KB
testcase_21 AC 86 ms
75,472 KB
testcase_22 AC 72 ms
71,164 KB
testcase_23 AC 72 ms
71,464 KB
testcase_24 AC 72 ms
71,536 KB
testcase_25 AC 72 ms
71,480 KB
testcase_26 AC 72 ms
71,420 KB
testcase_27 AC 72 ms
71,400 KB
testcase_28 AC 72 ms
71,380 KB
testcase_29 AC 86 ms
75,180 KB
testcase_30 AC 88 ms
75,212 KB
testcase_31 AC 78 ms
75,164 KB
testcase_32 AC 85 ms
75,436 KB
testcase_33 AC 83 ms
75,376 KB
testcase_34 AC 86 ms
75,668 KB
testcase_35 AC 85 ms
75,180 KB
testcase_36 AC 82 ms
75,648 KB
testcase_37 AC 86 ms
75,472 KB
testcase_38 AC 82 ms
75,376 KB
testcase_39 AC 89 ms
75,468 KB
testcase_40 AC 89 ms
75,200 KB
testcase_41 AC 83 ms
75,408 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