結果

問題 No.1809 Divide NCK
ユーザー SPD_9X2
提出日時 2022-01-14 21:42:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 81,992 KB
実行使用メモリ 58,368 KB
最終ジャッジ日時 2024-11-20 08:52:18
合計ジャッジ時間 3,860 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

def cont(x,M):

    ret = 0
    div = M
    while x >= div:
        ret += x // div
        div *= M
    return ret

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

q = {}
for i in range(2,10**6+1):

    if M % i == 0:
        q[i] = 0
        while M % i == 0:
            M //= i
            q[i] += 1

if M != 1:
    q[M] = 1

ans = float("inf")
for mod in q:
    ans =  min( ans , (cont(N,mod) - cont(K,mod) - cont(N-K,mod)) // q[mod] )
print (ans)
0