結果

問題 No.1809 Divide NCK
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-13 21:50:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 1,119 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-28 19:51:44
合計ジャッジ時間 3,747 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
11,648 KB
testcase_01 AC 37 ms
11,520 KB
testcase_02 AC 37 ms
11,520 KB
testcase_03 AC 37 ms
11,648 KB
testcase_04 AC 37 ms
11,648 KB
testcase_05 AC 35 ms
11,520 KB
testcase_06 AC 36 ms
11,520 KB
testcase_07 AC 36 ms
11,520 KB
testcase_08 AC 37 ms
11,648 KB
testcase_09 AC 35 ms
11,648 KB
testcase_10 AC 35 ms
11,648 KB
testcase_11 AC 35 ms
11,648 KB
testcase_12 AC 37 ms
11,648 KB
testcase_13 AC 44 ms
11,648 KB
testcase_14 AC 38 ms
11,520 KB
testcase_15 AC 35 ms
11,520 KB
testcase_16 AC 215 ms
11,648 KB
testcase_17 AC 41 ms
11,648 KB
testcase_18 AC 197 ms
11,648 KB
testcase_19 AC 213 ms
11,648 KB
testcase_20 AC 36 ms
11,520 KB
testcase_21 AC 37 ms
11,648 KB
testcase_22 AC 36 ms
11,648 KB
testcase_23 AC 37 ms
11,520 KB
testcase_24 AC 37 ms
11,648 KB
testcase_25 AC 37 ms
11,520 KB
testcase_26 AC 35 ms
11,520 KB
testcase_27 AC 36 ms
11,648 KB
testcase_28 AC 36 ms
11,648 KB
testcase_29 AC 136 ms
11,776 KB
testcase_30 AC 38 ms
11,648 KB
testcase_31 AC 36 ms
11,648 KB
testcase_32 AC 37 ms
11,520 KB
testcase_33 AC 53 ms
11,648 KB
testcase_34 AC 37 ms
11,648 KB
testcase_35 AC 40 ms
11,648 KB
testcase_36 AC 37 ms
11,648 KB
testcase_37 AC 35 ms
11,648 KB
testcase_38 AC 36 ms
11,776 KB
testcase_39 AC 36 ms
11,648 KB
testcase_40 AC 36 ms
11,648 KB
testcase_41 AC 36 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from copy import deepcopy as dcopy
import math
import sys
sys.setrecursionlimit(10**6)
def input():
    return sys.stdin.readline().rstrip()
def getN():
	return int(sys.stdin.readline())
def getNs():
	return map(int,sys.stdin.readline().split())
def getList():
	return list(map(int,sys.stdin.readline().split()))
def strinps(n):
	return [sys.stdin.readline().rstrip() for _ in range(n)]
pi = 3.141592653589793
mod = 10**9+7
MOD = 998244353
INF = math.inf
dx = [1,0,-1,0];	dy = [0,1,0,-1]

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

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

"""
Main Code
"""

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