結果

問題 No.1809 Divide NCK
ユーザー MasKoaTSMasKoaTS
提出日時 2021-12-22 11:16:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 59,312 KB
最終ジャッジ日時 2024-04-26 20:06:24
合計ジャッジ時間 3,352 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,280 KB
testcase_01 AC 55 ms
58,316 KB
testcase_02 AC 38 ms
52,256 KB
testcase_03 AC 37 ms
52,256 KB
testcase_04 AC 39 ms
52,256 KB
testcase_05 AC 38 ms
53,204 KB
testcase_06 AC 38 ms
52,948 KB
testcase_07 AC 38 ms
53,512 KB
testcase_08 AC 38 ms
53,816 KB
testcase_09 AC 37 ms
52,656 KB
testcase_10 AC 37 ms
53,356 KB
testcase_11 AC 50 ms
57,832 KB
testcase_12 AC 53 ms
58,836 KB
testcase_13 AC 43 ms
58,672 KB
testcase_14 AC 45 ms
58,480 KB
testcase_15 AC 42 ms
59,016 KB
testcase_16 AC 53 ms
58,196 KB
testcase_17 AC 40 ms
58,732 KB
testcase_18 AC 53 ms
57,452 KB
testcase_19 AC 54 ms
58,436 KB
testcase_20 AC 50 ms
58,328 KB
testcase_21 AC 50 ms
57,772 KB
testcase_22 AC 38 ms
52,904 KB
testcase_23 AC 38 ms
52,952 KB
testcase_24 AC 37 ms
52,536 KB
testcase_25 AC 37 ms
53,332 KB
testcase_26 AC 38 ms
53,224 KB
testcase_27 AC 38 ms
53,072 KB
testcase_28 AC 37 ms
52,196 KB
testcase_29 AC 50 ms
58,124 KB
testcase_30 AC 52 ms
57,920 KB
testcase_31 AC 42 ms
57,452 KB
testcase_32 AC 49 ms
58,188 KB
testcase_33 AC 46 ms
58,304 KB
testcase_34 AC 49 ms
59,228 KB
testcase_35 AC 49 ms
58,320 KB
testcase_36 AC 47 ms
58,184 KB
testcase_37 AC 52 ms
57,768 KB
testcase_38 AC 48 ms
59,228 KB
testcase_39 AC 53 ms
59,312 KB
testcase_40 AC 52 ms
58,904 KB
testcase_41 AC 48 ms
58,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

def prime_factorize(n):
	res = []
	for i in range(2, int(n ** 0.5) + 1):
		cnt = 0
		while(n % i == 0):
			n //= i
			cnt += 1
		if(cnt > 0):
			res.append((i, cnt))
	if(n > 1):
		res.append((n, 1))
	return res

def legendre(n,k,p):
	r = n - k
	res = 0
	while(n):
		n //= p
		res += n
	while(k):
		k //= p
		res -= k
	while(r):
		r //= p
		res -= r
	return res

ans = 10 ** 18
for p,c in prime_factorize(M):
	k = legendre(N,K,p) // c
	if(k < ans):
		ans = k
print(ans)
0