結果

問題 No.1809 Divide NCK
ユーザー H3PO4H3PO4
提出日時 2022-01-14 21:38:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 59,272 KB
最終ジャッジ日時 2024-04-30 13:21:37
合計ジャッジ時間 3,351 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,452 KB
testcase_01 AC 54 ms
58,188 KB
testcase_02 AC 39 ms
52,456 KB
testcase_03 AC 36 ms
52,080 KB
testcase_04 AC 38 ms
54,388 KB
testcase_05 AC 37 ms
54,268 KB
testcase_06 AC 39 ms
53,756 KB
testcase_07 AC 37 ms
53,680 KB
testcase_08 AC 37 ms
53,756 KB
testcase_09 AC 39 ms
53,148 KB
testcase_10 AC 37 ms
54,072 KB
testcase_11 AC 53 ms
57,760 KB
testcase_12 AC 55 ms
58,376 KB
testcase_13 AC 43 ms
57,984 KB
testcase_14 AC 45 ms
58,860 KB
testcase_15 AC 42 ms
58,332 KB
testcase_16 AC 56 ms
59,272 KB
testcase_17 AC 40 ms
58,648 KB
testcase_18 AC 54 ms
58,700 KB
testcase_19 AC 54 ms
58,332 KB
testcase_20 AC 53 ms
57,956 KB
testcase_21 AC 50 ms
58,700 KB
testcase_22 AC 37 ms
52,596 KB
testcase_23 AC 37 ms
52,624 KB
testcase_24 AC 38 ms
53,864 KB
testcase_25 AC 37 ms
53,472 KB
testcase_26 AC 38 ms
53,632 KB
testcase_27 AC 37 ms
53,152 KB
testcase_28 AC 38 ms
53,140 KB
testcase_29 AC 51 ms
57,976 KB
testcase_30 AC 53 ms
58,556 KB
testcase_31 AC 43 ms
58,672 KB
testcase_32 AC 49 ms
57,816 KB
testcase_33 AC 46 ms
58,168 KB
testcase_34 AC 49 ms
58,368 KB
testcase_35 AC 49 ms
58,572 KB
testcase_36 AC 47 ms
58,456 KB
testcase_37 AC 52 ms
58,048 KB
testcase_38 AC 46 ms
58,348 KB
testcase_39 AC 54 ms
58,712 KB
testcase_40 AC 53 ms
58,820 KB
testcase_41 AC 51 ms
59,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(n):
    arr = dict()
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if not arr and n != 1:
        arr[n] = 1

    return arr


def f(n, m):
    """n! が m**x で割り切れる最大のx"""
    res = 0
    while n:
        n //= m
        res += n
    return res


N, K, M = map(int, input().split())
fac = factorization(M)
ans = float("inf")
for k, v in fac.items():
    ans = min(ans, (f(N, k) - f(K, k) - f(N - K, k)) // v)
print(ans)
0