結果

問題 No.1330 Multiply or Divide
ユーザー Kude
提出日時 2021-01-08 22:00:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 119,568 KB
最終ジャッジ日時 2024-11-16 11:41:15
合計ジャッジ時間 5,365 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 44 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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 or mx == 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))
if not q:
    print(-1)
    exit()
dp = [0] * 100000
dp[0] = 1
for i in range(100000):
    if dp[i] >= t:
        print(i + 1)
        break
    for x, c in q:
        dp[i + c] = max(dp[i + c], dp[i] * x)
0