結果

問題 No.1330 Multiply or Divide
ユーザー wolgnikwolgnik
提出日時 2021-01-08 22:08:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 105,344 KB
最終ジャッジ日時 2024-04-28 03:16:08
合計ジャッジ時間 6,207 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 88 ms
103,424 KB
testcase_02 AC 38 ms
52,096 KB
testcase_03 AC 38 ms
51,840 KB
testcase_04 AC 38 ms
52,196 KB
testcase_05 AC 37 ms
51,712 KB
testcase_06 AC 146 ms
97,920 KB
testcase_07 AC 178 ms
105,344 KB
testcase_08 AC 163 ms
100,824 KB
testcase_09 AC 159 ms
100,692 KB
testcase_10 AC 155 ms
100,944 KB
testcase_11 AC 157 ms
101,056 KB
testcase_12 AC 157 ms
101,012 KB
testcase_13 AC 40 ms
51,840 KB
testcase_14 AC 46 ms
58,240 KB
testcase_15 AC 46 ms
57,856 KB
testcase_16 AC 42 ms
51,840 KB
testcase_17 AC 46 ms
57,600 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 114 ms
99,840 KB
testcase_24 AC 43 ms
51,712 KB
testcase_25 WA -
testcase_26 AC 43 ms
51,712 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 42 ms
51,968 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 180 ms
103,296 KB
testcase_45 AC 210 ms
103,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M, P = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
x = 1
res = 1000
for i in range(N):
  y = a[i]
  c = 0
  while y % P == 0:
    y //= P
    c += 1
  if y == 1: continue
  t = 1
  for j in range(31):
    if t * a[-1] > M:
      res = min(res, (c + 1) * j + 1)
      break
    t *= y


for i in range(100):
  if x > M or y > M:
    print(min(res, i))
    break
  for j in range(N - 1, -1, -1):
    if (x * a[j]) % P or (x * a[j]) > M:
      x *= a[j]
      break
else:
  if res != 1000: print(res)
  else: print(-1)
0