結果

問題 No.1330 Multiply or Divide
ユーザー Kude
提出日時 2021-01-08 21:46:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 119,936 KB
最終ジャッジ日時 2024-11-16 11:02:23
合計ジャッジ時間 9,269 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, p = map(int, input().split())
a = list(map(int, input().split()))
mx = max(a)
t = (m + mx - 1) // mx
if t == 1:
    print(1)
    exit()
q = []
for ai in a:
    cnt = 1
    while ai % p == 0:
        cnt += 1
        ai //= p
    if ai == 1:
        continue
    q.append((ai, cnt))

dp = [0] * 100
dp[0] = 1
for i in range(50):
    for x, c in q:
        dp[i + c] = max(dp[i + c], dp[i] * x)
for i, v in enumerate(dp):
    if v >= t:
        print(i + 1)
        break
else:
    print(-1)
0