結果

問題 No.1809 Divide NCK
ユーザー gr1msl3ygr1msl3y
提出日時 2022-01-15 00:11:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 59,572 KB
最終ジャッジ日時 2024-04-30 18:53:12
合計ジャッジ時間 2,776 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,660 KB
testcase_01 AC 49 ms
58,804 KB
testcase_02 AC 34 ms
52,812 KB
testcase_03 AC 31 ms
52,876 KB
testcase_04 AC 32 ms
52,940 KB
testcase_05 AC 31 ms
53,240 KB
testcase_06 AC 31 ms
52,720 KB
testcase_07 AC 32 ms
52,944 KB
testcase_08 AC 32 ms
52,324 KB
testcase_09 AC 31 ms
53,216 KB
testcase_10 AC 33 ms
52,972 KB
testcase_11 AC 46 ms
58,308 KB
testcase_12 AC 48 ms
58,240 KB
testcase_13 AC 37 ms
57,836 KB
testcase_14 AC 39 ms
57,872 KB
testcase_15 AC 35 ms
58,728 KB
testcase_16 AC 49 ms
57,912 KB
testcase_17 AC 39 ms
58,608 KB
testcase_18 AC 48 ms
59,572 KB
testcase_19 AC 48 ms
57,716 KB
testcase_20 AC 45 ms
57,764 KB
testcase_21 AC 44 ms
58,552 KB
testcase_22 AC 32 ms
53,136 KB
testcase_23 AC 31 ms
54,016 KB
testcase_24 AC 33 ms
52,468 KB
testcase_25 AC 32 ms
52,752 KB
testcase_26 AC 32 ms
52,348 KB
testcase_27 AC 33 ms
53,356 KB
testcase_28 AC 32 ms
53,580 KB
testcase_29 AC 46 ms
58,328 KB
testcase_30 AC 48 ms
58,400 KB
testcase_31 AC 39 ms
58,656 KB
testcase_32 AC 44 ms
57,896 KB
testcase_33 AC 42 ms
57,644 KB
testcase_34 AC 47 ms
58,116 KB
testcase_35 AC 45 ms
58,076 KB
testcase_36 AC 42 ms
58,472 KB
testcase_37 AC 46 ms
58,616 KB
testcase_38 AC 42 ms
57,924 KB
testcase_39 AC 45 ms
59,484 KB
testcase_40 AC 46 ms
58,052 KB
testcase_41 AC 41 ms
58,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K, M = map(int, input().split())


def count(x, p):
    res = 0
    v = p
    while v <= x:
        res += x//v
        v *= p
    return res


def factorization(n):
    if n == 1:
        return [[1, 1]]
    temp = n
    ans = []
    for i in range(2, int(n**0.5+1.01)):
        if temp % i == 0:
            ct = 0
            while temp % i == 0:
                temp //= i
                ct += 1
            ans.append([i, ct])
    if temp != 1:
        ans.append([temp, 1])
    return ans


A = factorization(M)
ans = 10**18
for p, c in A:
    v = count(N, p)-count(N-K, p)-count(K, p)
    ans = min(ans, v//c)
print(ans)
0