結果

問題 No.1809 Divide NCK
ユーザー H3PO4H3PO4
提出日時 2022-01-14 21:38:12
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 76,148 KB
最終ジャッジ日時 2023-08-12 18:14:57
合計ジャッジ時間 5,752 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,688 KB
testcase_01 AC 95 ms
75,792 KB
testcase_02 AC 73 ms
71,588 KB
testcase_03 AC 73 ms
71,824 KB
testcase_04 AC 73 ms
71,460 KB
testcase_05 AC 73 ms
71,796 KB
testcase_06 AC 72 ms
71,652 KB
testcase_07 AC 71 ms
71,756 KB
testcase_08 AC 73 ms
71,756 KB
testcase_09 AC 72 ms
71,704 KB
testcase_10 AC 72 ms
71,800 KB
testcase_11 AC 88 ms
75,916 KB
testcase_12 AC 89 ms
75,856 KB
testcase_13 AC 78 ms
75,672 KB
testcase_14 AC 79 ms
75,712 KB
testcase_15 AC 76 ms
75,772 KB
testcase_16 AC 89 ms
75,676 KB
testcase_17 AC 75 ms
75,684 KB
testcase_18 AC 87 ms
75,484 KB
testcase_19 AC 91 ms
75,548 KB
testcase_20 AC 88 ms
75,708 KB
testcase_21 AC 85 ms
75,732 KB
testcase_22 AC 72 ms
71,660 KB
testcase_23 AC 73 ms
71,836 KB
testcase_24 AC 74 ms
71,952 KB
testcase_25 AC 72 ms
71,884 KB
testcase_26 AC 75 ms
71,484 KB
testcase_27 AC 71 ms
71,656 KB
testcase_28 AC 71 ms
71,656 KB
testcase_29 AC 85 ms
75,716 KB
testcase_30 AC 85 ms
75,844 KB
testcase_31 AC 77 ms
75,528 KB
testcase_32 AC 84 ms
75,760 KB
testcase_33 AC 80 ms
75,636 KB
testcase_34 AC 83 ms
75,548 KB
testcase_35 AC 83 ms
75,640 KB
testcase_36 AC 79 ms
75,668 KB
testcase_37 AC 87 ms
75,852 KB
testcase_38 AC 81 ms
76,148 KB
testcase_39 AC 88 ms
75,648 KB
testcase_40 AC 86 ms
75,748 KB
testcase_41 AC 82 ms
75,784 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