結果

問題 No.1809 Divide NCK
ユーザー miscalcmiscalc
提出日時 2022-01-14 22:00:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,752 KB
実行使用メモリ 59,348 KB
最終ジャッジ日時 2024-04-30 14:38:21
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,332 KB
testcase_01 AC 53 ms
57,816 KB
testcase_02 AC 37 ms
53,428 KB
testcase_03 WA -
testcase_04 AC 34 ms
52,880 KB
testcase_05 AC 35 ms
52,708 KB
testcase_06 WA -
testcase_07 AC 33 ms
53,480 KB
testcase_08 AC 34 ms
52,696 KB
testcase_09 AC 32 ms
53,148 KB
testcase_10 AC 32 ms
52,340 KB
testcase_11 AC 46 ms
58,544 KB
testcase_12 AC 47 ms
59,348 KB
testcase_13 AC 37 ms
57,648 KB
testcase_14 AC 39 ms
57,940 KB
testcase_15 AC 37 ms
58,556 KB
testcase_16 AC 50 ms
57,304 KB
testcase_17 AC 36 ms
59,128 KB
testcase_18 AC 46 ms
58,404 KB
testcase_19 AC 47 ms
58,376 KB
testcase_20 WA -
testcase_21 AC 44 ms
59,188 KB
testcase_22 AC 32 ms
53,480 KB
testcase_23 AC 31 ms
53,288 KB
testcase_24 WA -
testcase_25 AC 35 ms
52,816 KB
testcase_26 AC 34 ms
52,624 KB
testcase_27 AC 32 ms
53,356 KB
testcase_28 AC 33 ms
52,464 KB
testcase_29 AC 46 ms
57,752 KB
testcase_30 WA -
testcase_31 AC 38 ms
58,172 KB
testcase_32 AC 42 ms
58,128 KB
testcase_33 WA -
testcase_34 AC 44 ms
57,804 KB
testcase_35 AC 45 ms
58,928 KB
testcase_36 AC 40 ms
58,460 KB
testcase_37 AC 46 ms
57,320 KB
testcase_38 AC 43 ms
58,528 KB
testcase_39 AC 48 ms
58,640 KB
testcase_40 AC 47 ms
59,236 KB
testcase_41 AC 41 ms
59,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorize(n):
  nn = n
  ret = []
  p = 2
  while p * p <= n:
    e = 0
    while nn % p == 0:
      nn //= p
      e += 1
    if e > 0:
      ret.append((p, e))
    p += 1
  if nn > 1:
    ret.append((n, 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