結果

問題 No.1809 Divide NCK
ユーザー 👑 H20H20
提出日時 2022-01-14 22:46:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 76,648 KB
最終ジャッジ日時 2023-08-12 21:20:02
合計ジャッジ時間 6,239 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,608 KB
testcase_01 AC 91 ms
71,624 KB
testcase_02 AC 92 ms
71,516 KB
testcase_03 AC 93 ms
71,524 KB
testcase_04 AC 90 ms
71,744 KB
testcase_05 AC 88 ms
71,736 KB
testcase_06 AC 88 ms
71,628 KB
testcase_07 AC 90 ms
71,332 KB
testcase_08 AC 91 ms
71,656 KB
testcase_09 AC 89 ms
71,736 KB
testcase_10 AC 89 ms
71,476 KB
testcase_11 AC 89 ms
71,608 KB
testcase_12 AC 90 ms
71,596 KB
testcase_13 AC 95 ms
76,452 KB
testcase_14 AC 92 ms
71,456 KB
testcase_15 AC 91 ms
71,700 KB
testcase_16 AC 102 ms
76,496 KB
testcase_17 AC 98 ms
76,324 KB
testcase_18 AC 104 ms
76,540 KB
testcase_19 AC 103 ms
76,648 KB
testcase_20 AC 97 ms
76,284 KB
testcase_21 AC 90 ms
71,748 KB
testcase_22 AC 92 ms
71,412 KB
testcase_23 AC 93 ms
71,596 KB
testcase_24 AC 90 ms
71,808 KB
testcase_25 AC 90 ms
71,808 KB
testcase_26 AC 91 ms
71,744 KB
testcase_27 AC 88 ms
71,776 KB
testcase_28 AC 92 ms
71,788 KB
testcase_29 AC 100 ms
76,396 KB
testcase_30 AC 96 ms
76,448 KB
testcase_31 AC 90 ms
71,332 KB
testcase_32 AC 90 ms
71,604 KB
testcase_33 AC 95 ms
76,364 KB
testcase_34 AC 93 ms
76,468 KB
testcase_35 AC 95 ms
76,368 KB
testcase_36 AC 96 ms
76,476 KB
testcase_37 AC 90 ms
71,424 KB
testcase_38 AC 90 ms
71,468 KB
testcase_39 AC 91 ms
71,596 KB
testcase_40 AC 91 ms
71,328 KB
testcase_41 AC 91 ms
71,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N,K,M = map(int, input().split())
CP = collections.Counter(prime_factorize(M))
L = []
for k,v in CP.items():
    L.append(k)

def func(N):
    C = collections.Counter()
    for l in L:
        i = 1
        while l**i<=N:
            C[l]+=N//(l**i)
            i+=1
    return C

CNK =  func(N)-func(N-K)-func(K)
ans = 10**20
for l in L:
    ans = min(ans,CNK[l]//CP[l])
print(ans)
0