結果

問題 No.1330 Multiply or Divide
ユーザー chineristACchineristAC
提出日時 2021-01-08 23:01:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 517 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 119,936 KB
最終ジャッジ日時 2024-04-28 04:47:26
合計ジャッジ時間 31,003 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,431 ms
109,184 KB
testcase_02 WA -
testcase_03 AC 40 ms
52,352 KB
testcase_04 AC 39 ms
51,840 KB
testcase_05 AC 45 ms
59,008 KB
testcase_06 AC 76 ms
97,024 KB
testcase_07 WA -
testcase_08 AC 1,388 ms
117,460 KB
testcase_09 AC 1,501 ms
117,900 KB
testcase_10 AC 1,252 ms
117,596 KB
testcase_11 AC 1,512 ms
117,548 KB
testcase_12 AC 1,381 ms
117,720 KB
testcase_13 AC 48 ms
60,160 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 46 ms
59,648 KB
testcase_17 WA -
testcase_18 AC 1,446 ms
117,452 KB
testcase_19 AC 1,429 ms
117,596 KB
testcase_20 AC 1,428 ms
117,336 KB
testcase_21 AC 1,442 ms
117,200 KB
testcase_22 AC 1,441 ms
117,844 KB
testcase_23 WA -
testcase_24 AC 46 ms
59,392 KB
testcase_25 AC 45 ms
59,008 KB
testcase_26 WA -
testcase_27 AC 40 ms
52,480 KB
testcase_28 AC 45 ms
59,392 KB
testcase_29 AC 46 ms
59,392 KB
testcase_30 AC 45 ms
58,880 KB
testcase_31 AC 45 ms
59,264 KB
testcase_32 AC 45 ms
59,136 KB
testcase_33 AC 45 ms
59,264 KB
testcase_34 AC 1,072 ms
105,344 KB
testcase_35 AC 334 ms
84,480 KB
testcase_36 AC 965 ms
106,880 KB
testcase_37 AC 867 ms
105,472 KB
testcase_38 AC 562 ms
93,056 KB
testcase_39 AC 401 ms
85,888 KB
testcase_40 AC 476 ms
89,216 KB
testcase_41 AC 273 ms
80,512 KB
testcase_42 AC 804 ms
102,400 KB
testcase_43 AC 929 ms
106,228 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,P = map(int,input().split())
A = list(map(int,input().split()))

B = []
for a in A:
    cost = 1
    while a%P==0:
        a //= P
        cost += 1
    if a!=1:
        B.append((cost,a))

n = len(B)
dp = [1 for i in range(701)]
for i in range(n):
    cost,a = B[i]
    next = [dp[j] for j in range(701)]
    for j in range(701-cost):
        next[j+cost] = max(next[j+cost],min(M,dp[j]*a),min(M,next[j]*a))
    dp = next

for i in range(701):
    if dp[i]==M:
        print(i)
        break
else:
    print(-1)
0