結果

問題 No.1330 Multiply or Divide
コンテスト
ユーザー ああ
提出日時 2026-05-18 01:39:04
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 540 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 408 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 142,208 KB
最終ジャッジ日時 2026-05-18 01:39:16
合計ジャッジ時間 6,800 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def aa(s):
    global m
    if s>=m:
        return 0
    if s in v:
        return v[s]
    res=1<<30
    for i in range(1,len(y)):
    	if y[i]:
    		res=min(res,aa(s*y[i])+i)
    v[s]=res
    return res


n,m,p=map(int,input().split())
a=list(map(int,input().split()))
x={}
for i in a:
    d=1
    while i%p==0:
        i//=p;d+=1
    if i==1:
        continue
    if i in x:
        x[i]=min(x[i],d)
    else:
        x[i]=d
if len(x)==0:
    print(-1)
    exit()
y=[0]*61
for i,j in x.items():
	y[j]=max(y[j],i)
v={}
aa(1);print(v[1])
0