結果

問題 No.1330 Multiply or Divide
ユーザー marroncastlemarroncastle
提出日時 2021-01-20 19:58:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 107,564 KB
最終ジャッジ日時 2023-08-24 23:55:57
合計ジャッジ時間 7,808 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,712 KB
testcase_01 AC 138 ms
107,564 KB
testcase_02 AC 88 ms
71,612 KB
testcase_03 AC 87 ms
71,528 KB
testcase_04 AC 90 ms
71,728 KB
testcase_05 AC 89 ms
71,732 KB
testcase_06 AC 131 ms
106,040 KB
testcase_07 AC 152 ms
107,536 KB
testcase_08 AC 153 ms
100,372 KB
testcase_09 AC 155 ms
100,612 KB
testcase_10 AC 152 ms
100,616 KB
testcase_11 AC 150 ms
100,280 KB
testcase_12 AC 154 ms
100,504 KB
testcase_13 AC 91 ms
71,496 KB
testcase_14 AC 88 ms
71,716 KB
testcase_15 AC 90 ms
71,412 KB
testcase_16 AC 87 ms
71,596 KB
testcase_17 AC 88 ms
71,784 KB
testcase_18 AC 141 ms
100,600 KB
testcase_19 AC 141 ms
100,436 KB
testcase_20 AC 143 ms
100,660 KB
testcase_21 AC 143 ms
100,152 KB
testcase_22 AC 142 ms
100,256 KB
testcase_23 AC 143 ms
102,284 KB
testcase_24 AC 88 ms
71,704 KB
testcase_25 AC 88 ms
71,568 KB
testcase_26 AC 88 ms
71,612 KB
testcase_27 AC 90 ms
71,624 KB
testcase_28 AC 90 ms
71,612 KB
testcase_29 AC 88 ms
71,668 KB
testcase_30 AC 89 ms
71,340 KB
testcase_31 AC 87 ms
71,692 KB
testcase_32 AC 89 ms
71,608 KB
testcase_33 AC 90 ms
71,540 KB
testcase_34 AC 130 ms
101,864 KB
testcase_35 AC 104 ms
82,648 KB
testcase_36 AC 127 ms
99,076 KB
testcase_37 AC 121 ms
96,836 KB
testcase_38 AC 112 ms
88,248 KB
testcase_39 AC 109 ms
82,628 KB
testcase_40 AC 110 ms
85,760 KB
testcase_41 AC 100 ms
80,896 KB
testcase_42 AC 120 ms
95,092 KB
testcase_43 AC 122 ms
96,764 KB
testcase_44 AC 135 ms
105,976 KB
testcase_45 AC 136 ms
106,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, P = map(int, input().split())
A = list(map(int, input().split()))
maxa = max(A)
from collections import defaultdict
dp = defaultdict(lambda: 0)
cnts = [1]*30
for i in range(N):
  cnt = 0
  while A[i]%P==0:
    cnt += 1
    A[i] //= P
  cnts[cnt] = max(cnts[cnt], A[i])
dp[0] = 1
if max(A)==1 and maxa<=M:
  print(-1)
  exit()
ans = 0
p = 1
while p*maxa <= M:
  for i in range(30):
    dp[ans+i+1] = max(dp[ans+i+1], p*cnts[i])
  ans += 1
  p = dp[ans]
if p>M:
  print(ans)
else:
  print(ans+1)
0