結果

問題 No.1809 Divide NCK
ユーザー とりゐとりゐ
提出日時 2022-01-14 22:03:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 75,820 KB
最終ジャッジ日時 2023-08-12 19:44:11
合計ジャッジ時間 5,164 ms
ジャッジサーバーID
(参考情報)
judge14 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,396 KB
testcase_01 AC 107 ms
75,564 KB
testcase_02 AC 66 ms
71,696 KB
testcase_03 AC 65 ms
71,912 KB
testcase_04 AC 71 ms
71,576 KB
testcase_05 AC 68 ms
71,592 KB
testcase_06 AC 68 ms
71,452 KB
testcase_07 AC 66 ms
71,656 KB
testcase_08 AC 63 ms
71,604 KB
testcase_09 AC 65 ms
71,568 KB
testcase_10 AC 64 ms
71,472 KB
testcase_11 AC 79 ms
75,448 KB
testcase_12 AC 79 ms
75,340 KB
testcase_13 AC 68 ms
75,448 KB
testcase_14 AC 72 ms
75,720 KB
testcase_15 AC 66 ms
75,544 KB
testcase_16 AC 86 ms
75,444 KB
testcase_17 AC 68 ms
75,596 KB
testcase_18 AC 80 ms
75,444 KB
testcase_19 AC 83 ms
75,612 KB
testcase_20 AC 77 ms
75,344 KB
testcase_21 AC 75 ms
75,544 KB
testcase_22 AC 64 ms
71,652 KB
testcase_23 AC 64 ms
71,392 KB
testcase_24 AC 65 ms
71,608 KB
testcase_25 AC 63 ms
71,480 KB
testcase_26 AC 65 ms
71,360 KB
testcase_27 AC 65 ms
71,504 KB
testcase_28 AC 66 ms
71,392 KB
testcase_29 AC 79 ms
75,592 KB
testcase_30 AC 81 ms
75,444 KB
testcase_31 AC 70 ms
75,720 KB
testcase_32 AC 76 ms
75,600 KB
testcase_33 AC 73 ms
75,332 KB
testcase_34 AC 76 ms
75,600 KB
testcase_35 AC 76 ms
75,576 KB
testcase_36 AC 74 ms
75,548 KB
testcase_37 AC 81 ms
75,820 KB
testcase_38 AC 77 ms
75,580 KB
testcase_39 AC 83 ms
75,436 KB
testcase_40 AC 83 ms
75,808 KB
testcase_41 AC 78 ms
75,332 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