結果

問題 No.1330 Multiply or Divide
ユーザー chineristACchineristAC
提出日時 2021-01-08 23:03:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 120,188 KB
最終ジャッジ日時 2024-04-28 04:51:05
合計ジャッジ時間 27,374 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,275 ms
109,696 KB
testcase_02 WA -
testcase_03 AC 35 ms
52,096 KB
testcase_04 AC 35 ms
51,840 KB
testcase_05 AC 44 ms
59,264 KB
testcase_06 AC 77 ms
97,280 KB
testcase_07 WA -
testcase_08 AC 1,248 ms
117,972 KB
testcase_09 AC 1,346 ms
117,676 KB
testcase_10 AC 1,072 ms
117,740 KB
testcase_11 AC 1,321 ms
117,660 KB
testcase_12 AC 1,207 ms
117,784 KB
testcase_13 AC 46 ms
60,032 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 46 ms
59,392 KB
testcase_17 WA -
testcase_18 AC 1,266 ms
117,716 KB
testcase_19 AC 1,296 ms
117,856 KB
testcase_20 AC 1,263 ms
118,116 KB
testcase_21 AC 1,276 ms
117,724 KB
testcase_22 AC 1,277 ms
117,668 KB
testcase_23 AC 1,073 ms
117,500 KB
testcase_24 AC 45 ms
59,392 KB
testcase_25 AC 44 ms
59,776 KB
testcase_26 AC 43 ms
59,136 KB
testcase_27 AC 36 ms
52,608 KB
testcase_28 AC 42 ms
59,008 KB
testcase_29 AC 42 ms
59,392 KB
testcase_30 AC 43 ms
59,008 KB
testcase_31 AC 42 ms
59,520 KB
testcase_32 AC 43 ms
59,392 KB
testcase_33 AC 42 ms
59,776 KB
testcase_34 AC 943 ms
105,344 KB
testcase_35 AC 312 ms
84,344 KB
testcase_36 AC 853 ms
107,336 KB
testcase_37 AC 774 ms
105,772 KB
testcase_38 AC 515 ms
93,428 KB
testcase_39 AC 378 ms
85,708 KB
testcase_40 AC 448 ms
89,216 KB
testcase_41 AC 253 ms
80,768 KB
testcase_42 AC 722 ms
102,272 KB
testcase_43 AC 822 ms
106,244 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+1,dp[j]*a),min(M+1,next[j]*a))
    dp = next

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