結果

問題 No.1809 Divide NCK
ユーザー miscalcmiscalc
提出日時 2022-01-14 22:00:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 75,640 KB
最終ジャッジ日時 2023-08-12 19:36:36
合計ジャッジ時間 5,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,472 KB
testcase_01 AC 71 ms
71,448 KB
testcase_02 AC 72 ms
71,388 KB
testcase_03 AC 71 ms
71,232 KB
testcase_04 AC 71 ms
71,540 KB
testcase_05 AC 69 ms
71,372 KB
testcase_06 AC 69 ms
71,480 KB
testcase_07 AC 70 ms
71,296 KB
testcase_08 AC 68 ms
71,300 KB
testcase_09 AC 70 ms
71,304 KB
testcase_10 AC 70 ms
71,404 KB
testcase_11 AC 72 ms
71,308 KB
testcase_12 AC 70 ms
71,308 KB
testcase_13 AC 72 ms
75,636 KB
testcase_14 AC 67 ms
71,440 KB
testcase_15 AC 71 ms
71,408 KB
testcase_16 AC 89 ms
75,640 KB
testcase_17 AC 74 ms
75,632 KB
testcase_18 AC 85 ms
75,200 KB
testcase_19 AC 89 ms
75,300 KB
testcase_20 AC 70 ms
75,304 KB
testcase_21 AC 71 ms
71,312 KB
testcase_22 AC 70 ms
71,448 KB
testcase_23 AC 70 ms
71,512 KB
testcase_24 AC 69 ms
71,452 KB
testcase_25 AC 71 ms
71,236 KB
testcase_26 AC 71 ms
71,080 KB
testcase_27 AC 67 ms
71,616 KB
testcase_28 AC 70 ms
71,376 KB
testcase_29 AC 81 ms
75,580 KB
testcase_30 AC 74 ms
75,428 KB
testcase_31 AC 73 ms
75,364 KB
testcase_32 AC 70 ms
71,404 KB
testcase_33 AC 74 ms
75,472 KB
testcase_34 AC 73 ms
75,572 KB
testcase_35 AC 74 ms
75,308 KB
testcase_36 AC 71 ms
75,196 KB
testcase_37 AC 68 ms
71,604 KB
testcase_38 AC 71 ms
71,316 KB
testcase_39 AC 72 ms
71,240 KB
testcase_40 AC 70 ms
71,308 KB
testcase_41 AC 71 ms
71,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorize(n):
  nn = n
  ret = []
  p = 2
  while p * p <= nn:
    e = 0
    while nn % p == 0:
      nn //= p
      e += 1
    if e > 0:
      ret.append((p, e))
    p += 1
  if nn > 1:
    ret.append((nn, 1))
  return ret

def f(n, p):
  ret = 0
  k = p
  while k <= n:
    ret += n // k
    k *= p
  return ret

n, k, m = map(int, input().split())
pes = factorize(m)

ans = 10 ** 100
for pe in pes:
  p, e = pe[0], pe[1]
  e2 = f(n, p) - f(n - k, p) - f(k, p)
  tmp = e2 // e
  ans = min(ans, tmp)
print(ans)
0