結果

問題 No.1809 Divide NCK
ユーザー tktk_snsntktk_snsn
提出日時 2022-01-14 22:33:36
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 7,932 KB
最終ジャッジ日時 2023-08-12 20:56:35
合計ジャッジ時間 3,600 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,876 KB
testcase_01 AC 70 ms
7,776 KB
testcase_02 AC 15 ms
7,760 KB
testcase_03 AC 15 ms
7,776 KB
testcase_04 AC 15 ms
7,760 KB
testcase_05 AC 16 ms
7,780 KB
testcase_06 AC 16 ms
7,824 KB
testcase_07 AC 20 ms
7,748 KB
testcase_08 AC 16 ms
7,796 KB
testcase_09 AC 15 ms
7,808 KB
testcase_10 AC 15 ms
7,788 KB
testcase_11 AC 59 ms
7,776 KB
testcase_12 AC 69 ms
7,768 KB
testcase_13 AC 27 ms
7,780 KB
testcase_14 AC 35 ms
7,856 KB
testcase_15 AC 19 ms
7,884 KB
testcase_16 AC 98 ms
7,744 KB
testcase_17 AC 18 ms
7,824 KB
testcase_18 AC 91 ms
7,700 KB
testcase_19 AC 98 ms
7,812 KB
testcase_20 AC 65 ms
7,768 KB
testcase_21 AC 53 ms
7,780 KB
testcase_22 AC 16 ms
7,760 KB
testcase_23 AC 15 ms
7,776 KB
testcase_24 AC 15 ms
7,904 KB
testcase_25 AC 15 ms
7,900 KB
testcase_26 AC 16 ms
7,916 KB
testcase_27 AC 16 ms
7,800 KB
testcase_28 AC 16 ms
7,820 KB
testcase_29 AC 80 ms
7,776 KB
testcase_30 AC 71 ms
7,876 KB
testcase_31 AC 25 ms
7,704 KB
testcase_32 AC 49 ms
7,824 KB
testcase_33 AC 57 ms
7,796 KB
testcase_34 AC 62 ms
7,788 KB
testcase_35 AC 53 ms
7,768 KB
testcase_36 AC 47 ms
7,800 KB
testcase_37 AC 64 ms
7,880 KB
testcase_38 AC 45 ms
7,748 KB
testcase_39 AC 67 ms
7,900 KB
testcase_40 AC 64 ms
7,788 KB
testcase_41 AC 46 ms
7,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


def count(N, p):
    """N!がpで何回割れるか"""
    res = 0
    v = 1
    for _ in range(100):
        v *= p
        if v > N:
            break
        res += N // v
    return res


N, K, M = map(int, input().split())
pf = prime_factorization(M)
X = 10 ** 18
for p, f in pf:
    tot = count(N, p) - count(K, p) - count(N - K, p)
    X = min(X, tot // f)
print(X)
0