結果

問題 No.1330 Multiply or Divide
ユーザー Kite_kuma
提出日時 2021-01-08 21:35:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 60,272 KB
最終ジャッジ日時 2024-11-16 10:27:58
合計ジャッジ時間 15,526 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42 WA * 1 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, p = map(int, input().split())
a = list(map(int, input().split()))
d = list()

flag = True
for c in a:
    tmp = 0
    while c % p == 0:
        c //= p
        tmp += 1
    if c > 1:
        flag = False
    d.append(tmp)
if flag:
    print(-1)
    exit()
dp = [1] * (100000)

ans = 0
x = 1
y = max(a)

# print(d)

for i in range(100000):
    now = dp[i]
    if now > m:
        print(i)
        exit()
    for j in range(n):
        c = a[j]
        if now * c > m:
            print(i + 1)
            exit()
        dp[i+d[j]+1] = max(dp[i+d[j]+1], now*c//(p**d[j]))
        # print(i,d[j],j,now)
0