結果
| 問題 | No.1330 Multiply or Divide |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-20 19:58:33 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 110 ms / 2,000 ms |
| + 323µs | |
| コード長 | 500 bytes |
| 記録 | |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 96,492 KB |
| 実行使用メモリ | 118,588 KB |
| 最終ジャッジ日時 | 2026-07-12 08:47:29 |
| 合計ジャッジ時間 | 6,855 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 51 |
ソースコード
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)