結果

問題 No.1330 Multiply or Divide
ユーザー Kite_kumaKite_kuma
提出日時 2021-01-08 21:35:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 36,316 KB
最終ジャッジ日時 2024-04-28 02:15:30
合計ジャッジ時間 4,678 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
17,024 KB
testcase_01 AC 314 ms
29,580 KB
testcase_02 WA -
testcase_03 AC 27 ms
11,520 KB
testcase_04 AC 27 ms
10,880 KB
testcase_05 AC 28 ms
11,520 KB
testcase_06 AC 136 ms
14,776 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

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