結果

問題 No.1809 Divide NCK
ユーザー miscalcmiscalc
提出日時 2022-01-14 22:00:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 82,696 KB
実行使用メモリ 59,456 KB
最終ジャッジ日時 2024-04-30 14:41:28
合計ジャッジ時間 3,380 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,000 KB
testcase_01 AC 41 ms
52,948 KB
testcase_02 AC 41 ms
52,200 KB
testcase_03 AC 40 ms
52,988 KB
testcase_04 AC 41 ms
52,756 KB
testcase_05 AC 41 ms
53,292 KB
testcase_06 AC 41 ms
52,004 KB
testcase_07 AC 41 ms
52,960 KB
testcase_08 AC 41 ms
52,400 KB
testcase_09 AC 40 ms
53,264 KB
testcase_10 AC 40 ms
53,168 KB
testcase_11 AC 41 ms
53,332 KB
testcase_12 AC 39 ms
53,824 KB
testcase_13 AC 44 ms
57,340 KB
testcase_14 AC 41 ms
53,316 KB
testcase_15 AC 40 ms
53,144 KB
testcase_16 AC 59 ms
58,184 KB
testcase_17 AC 45 ms
58,112 KB
testcase_18 AC 57 ms
57,856 KB
testcase_19 AC 58 ms
59,332 KB
testcase_20 AC 44 ms
57,660 KB
testcase_21 AC 41 ms
53,356 KB
testcase_22 AC 40 ms
53,704 KB
testcase_23 AC 40 ms
52,988 KB
testcase_24 AC 40 ms
52,332 KB
testcase_25 AC 40 ms
52,012 KB
testcase_26 AC 39 ms
53,328 KB
testcase_27 AC 41 ms
53,276 KB
testcase_28 AC 39 ms
53,540 KB
testcase_29 AC 52 ms
57,936 KB
testcase_30 AC 44 ms
59,456 KB
testcase_31 AC 42 ms
57,600 KB
testcase_32 AC 39 ms
53,452 KB
testcase_33 AC 46 ms
59,120 KB
testcase_34 AC 44 ms
58,280 KB
testcase_35 AC 44 ms
57,668 KB
testcase_36 AC 42 ms
58,364 KB
testcase_37 AC 40 ms
52,524 KB
testcase_38 AC 41 ms
52,884 KB
testcase_39 AC 41 ms
52,712 KB
testcase_40 AC 42 ms
53,088 KB
testcase_41 AC 41 ms
53,016 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