結果

問題 No.1809 Divide NCK
ユーザー 👑 H20H20
提出日時 2022-01-14 22:46:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 60,740 KB
最終ジャッジ日時 2024-04-30 16:25:27
合計ジャッジ時間 2,962 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
54,316 KB
testcase_01 AC 34 ms
54,504 KB
testcase_02 AC 35 ms
55,384 KB
testcase_03 AC 36 ms
55,708 KB
testcase_04 AC 35 ms
54,852 KB
testcase_05 AC 34 ms
54,520 KB
testcase_06 AC 35 ms
54,548 KB
testcase_07 AC 36 ms
54,976 KB
testcase_08 AC 40 ms
54,900 KB
testcase_09 AC 36 ms
55,732 KB
testcase_10 AC 34 ms
54,868 KB
testcase_11 AC 36 ms
54,220 KB
testcase_12 AC 35 ms
54,404 KB
testcase_13 AC 39 ms
60,556 KB
testcase_14 AC 34 ms
54,624 KB
testcase_15 AC 36 ms
54,028 KB
testcase_16 AC 47 ms
59,548 KB
testcase_17 AC 43 ms
60,324 KB
testcase_18 AC 46 ms
59,656 KB
testcase_19 AC 44 ms
60,104 KB
testcase_20 AC 37 ms
58,952 KB
testcase_21 AC 36 ms
55,032 KB
testcase_22 AC 34 ms
53,852 KB
testcase_23 AC 36 ms
54,940 KB
testcase_24 AC 35 ms
54,116 KB
testcase_25 AC 34 ms
54,976 KB
testcase_26 AC 35 ms
54,064 KB
testcase_27 AC 36 ms
54,492 KB
testcase_28 AC 35 ms
54,016 KB
testcase_29 AC 42 ms
60,224 KB
testcase_30 AC 37 ms
60,048 KB
testcase_31 AC 36 ms
54,560 KB
testcase_32 AC 35 ms
54,784 KB
testcase_33 AC 37 ms
59,772 KB
testcase_34 AC 37 ms
59,384 KB
testcase_35 AC 37 ms
60,740 KB
testcase_36 AC 39 ms
59,904 KB
testcase_37 AC 35 ms
54,272 KB
testcase_38 AC 39 ms
54,380 KB
testcase_39 AC 37 ms
54,400 KB
testcase_40 AC 35 ms
54,732 KB
testcase_41 AC 36 ms
54,692 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