結果

問題 No.1330 Multiply or Divide
ユーザー aaaaaaaaaa2230
提出日時 2021-01-09 15:08:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,169 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 32,388 KB
最終ジャッジ日時 2025-06-20 01:24:46
合計ジャッジ時間 7,193 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,p = map(int,input().split())
a = list(map(int,input().split()))
ans = float("INF")
ma = max(a)
if ma > m:
    print(1)
    exit()
MAX = [0]*40
for i in a:
    now = i
    count = 1
    while now%p == 0:
        now //= p
        count += 1
    if now == 1:
        continue
    MAX[count] = max(MAX[count],now)
dp = [0]*2000
dp[0] = 1
for i in range(1600):
    if ma * dp[i] > m:
        print(i+1)
        exit()
    for j in range(40):
        dp[i+j] = max(dp[i+j],dp[i]*MAX[j])
print(-1)
0