結果

問題 No.1809 Divide NCK
ユーザー MasKoaTS
提出日時 2021-12-09 13:01:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 59,240 KB
最終ジャッジ日時 2024-07-17 06:35:20
合計ジャッジ時間 2,997 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#嘘解法

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

def prime_factorize(n):
	prime = []
	f = 2
	while(f * f <= n):
		if(n % f == 0):
			n //= f
			cnt = 1
			while(n % f == 0):
				n //= f
				cnt += 1
			prime.append((f,cnt))
		else:
			f += 1
	if(n != 1):
		prime.append((n,1))
	return prime

def legendre(N,K,p,c):
	R = N - K
	cnt = 0
	while(N):
		N //= p
		cnt += N
	while(K):
		K //= p
		cnt -= K
	while(R):
		R //= p
		cnt -= R
	return cnt // c

prime = prime_factorize(M)
ans = legendre(N,K,prime[-1][0],prime[-1][1])

print(ans)
0