結果

問題 No.1330 Multiply or Divide
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-14 08:14:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 1,523 ms
コンパイル使用メモリ 86,460 KB
実行使用メモリ 109,184 KB
最終ジャッジ日時 2023-09-28 18:59:09
合計ジャッジ時間 7,680 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 141 ms
109,060 KB
testcase_02 AC 75 ms
71,308 KB
testcase_03 AC 78 ms
71,080 KB
testcase_04 AC 75 ms
71,004 KB
testcase_05 AC 76 ms
71,196 KB
testcase_06 AC 128 ms
106,040 KB
testcase_07 AC 221 ms
109,184 KB
testcase_08 AC 153 ms
101,388 KB
testcase_09 AC 158 ms
101,432 KB
testcase_10 AC 149 ms
101,408 KB
testcase_11 AC 149 ms
101,748 KB
testcase_12 AC 158 ms
101,900 KB
testcase_13 AC 78 ms
71,280 KB
testcase_14 AC 77 ms
71,436 KB
testcase_15 AC 77 ms
71,104 KB
testcase_16 AC 78 ms
71,248 KB
testcase_17 AC 79 ms
71,180 KB
testcase_18 AC 135 ms
101,152 KB
testcase_19 AC 137 ms
101,204 KB
testcase_20 AC 134 ms
101,156 KB
testcase_21 AC 135 ms
101,432 KB
testcase_22 AC 133 ms
101,432 KB
testcase_23 AC 140 ms
103,612 KB
testcase_24 AC 75 ms
71,340 KB
testcase_25 AC 74 ms
71,120 KB
testcase_26 AC 75 ms
71,196 KB
testcase_27 AC 76 ms
71,180 KB
testcase_28 AC 78 ms
71,044 KB
testcase_29 AC 77 ms
71,240 KB
testcase_30 AC 77 ms
71,244 KB
testcase_31 AC 77 ms
71,116 KB
testcase_32 AC 78 ms
71,220 KB
testcase_33 AC 78 ms
71,116 KB
testcase_34 AC 120 ms
102,008 KB
testcase_35 AC 93 ms
80,992 KB
testcase_36 AC 114 ms
98,744 KB
testcase_37 AC 109 ms
96,116 KB
testcase_38 AC 98 ms
87,356 KB
testcase_39 AC 90 ms
82,108 KB
testcase_40 AC 97 ms
84,804 KB
testcase_41 AC 88 ms
78,960 KB
testcase_42 AC 107 ms
93,640 KB
testcase_43 AC 114 ms
96,604 KB
testcase_44 AC 130 ms
106,052 KB
testcase_45 AC 130 ms
105,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main1(n,m,p,a):
  if any([x>m for x in a]):return 1
  bd=m
  mxvary=[-1]*31
  for x in a:
    bd=min(bd,(m+1+x-1)//x)
    cnt=0
    while x%p==0:
      cnt+=1
      x//=p
    mxvary[cnt]=max(mxvary[cnt],x)
  if all([abs(x)==1 for x in mxvary]):return -1
  ans=float('inf')
  for i in range(31):
    if abs(mxvary[i])==1:continue
    mxv=mxvary[i]
    tmp=0
    now=1
    while now<=bd:
      now*=mxv
      tmp+=i+1
    if now>m:
      ans=min(ans,tmp)
    else:
      ans=min(ans,tmp+1)
  return ans

if __name__=='__main__':
  n,m,p=map(int,input().split())
  a=list(map(int,input().split()))
  ret1=main1(n,m,p,a)
  print(ret1)
0