結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-20 19:58:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 500 bytes |
| コンパイル時間 | 162 ms |
| コンパイル使用メモリ | 82,352 KB |
| 実行使用メモリ | 107,036 KB |
| 最終ジャッジ日時 | 2025-06-20 01:27:12 |
| 合計ジャッジ時間 | 4,859 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)