結果

問題 No.1330 Multiply or Divide
ユーザー googol_S0
提出日時 2021-01-08 21:25:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 364 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,060 KB
実行使用メモリ 147,860 KB
最終ジャッジ日時 2024-11-16 10:04:48
合計ジャッジ時間 9,240 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,P=map(int,input().split())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
  B.append(A[i])
  C.append(1)
  while B[i]%P==0:
    B[i]//=P
    C[i]+=1
Z=max(A)
X=(M+Z-1)//Z
if max(B)==1 and X>1:
  print(-1)
  exit()
D=[[B[i],C[i]] for i in range(N)]
D.sort(key=lambda x:(x[0]**(1/x[1])))
P=0
Y=1
while Y*Z<M:
  Y*=D[-1][0]
  P+=D[-1][1]
print(P+1)
0