結果

問題 No.1809 Divide NCK
ユーザー とりゐとりゐ
提出日時 2022-01-14 22:03:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 59,408 KB
最終ジャッジ日時 2024-04-30 14:48:41
合計ジャッジ時間 2,789 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,644 KB
testcase_01 AC 50 ms
58,052 KB
testcase_02 AC 34 ms
52,692 KB
testcase_03 AC 35 ms
52,964 KB
testcase_04 AC 33 ms
52,724 KB
testcase_05 AC 33 ms
53,444 KB
testcase_06 AC 33 ms
53,628 KB
testcase_07 AC 31 ms
52,880 KB
testcase_08 AC 33 ms
52,452 KB
testcase_09 AC 31 ms
52,828 KB
testcase_10 AC 31 ms
52,348 KB
testcase_11 AC 44 ms
58,040 KB
testcase_12 AC 52 ms
58,968 KB
testcase_13 AC 38 ms
57,760 KB
testcase_14 AC 39 ms
59,048 KB
testcase_15 AC 35 ms
58,040 KB
testcase_16 AC 45 ms
58,012 KB
testcase_17 AC 35 ms
57,828 KB
testcase_18 AC 45 ms
59,408 KB
testcase_19 AC 47 ms
58,584 KB
testcase_20 AC 44 ms
58,284 KB
testcase_21 AC 43 ms
58,736 KB
testcase_22 AC 31 ms
53,220 KB
testcase_23 AC 32 ms
52,460 KB
testcase_24 AC 31 ms
53,764 KB
testcase_25 AC 32 ms
52,260 KB
testcase_26 AC 32 ms
53,516 KB
testcase_27 AC 32 ms
53,900 KB
testcase_28 AC 30 ms
53,312 KB
testcase_29 AC 43 ms
58,672 KB
testcase_30 AC 44 ms
59,028 KB
testcase_31 AC 36 ms
57,976 KB
testcase_32 AC 41 ms
57,836 KB
testcase_33 AC 41 ms
58,668 KB
testcase_34 AC 47 ms
57,504 KB
testcase_35 AC 44 ms
58,272 KB
testcase_36 AC 41 ms
59,360 KB
testcase_37 AC 45 ms
57,456 KB
testcase_38 AC 43 ms
58,304 KB
testcase_39 AC 48 ms
58,548 KB
testcase_40 AC 45 ms
58,000 KB
testcase_41 AC 40 ms
57,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def fact(n):
  #fact(18)=[[2, 1],[3, 2]] (18 = 2**1 * 3**2)
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

n,k,m=map(int,input().split())
f=fact(m)
ans=10**18
for p,a in f:
  cnt=0
  tmp=p
  while tmp<1<<63:
    cnt+=n//tmp-(n-k)//tmp
    cnt-=k//tmp
    tmp*=p
  ans=min(ans,cnt//a)
print(ans)
0