結果

問題 No.1330 Multiply or Divide
ユーザー wolgnikwolgnik
提出日時 2021-01-08 22:15:38
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 574 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 106,400 KB
最終ジャッジ日時 2023-08-10 12:29:28
合計ジャッジ時間 7,533 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 118 ms
105,780 KB
testcase_02 AC 69 ms
71,372 KB
testcase_03 AC 69 ms
71,272 KB
testcase_04 AC 71 ms
71,440 KB
testcase_05 AC 70 ms
71,452 KB
testcase_06 AC 174 ms
104,340 KB
testcase_07 AC 205 ms
106,400 KB
testcase_08 AC 171 ms
102,072 KB
testcase_09 AC 171 ms
101,992 KB
testcase_10 AC 169 ms
102,244 KB
testcase_11 AC 169 ms
102,428 KB
testcase_12 AC 168 ms
102,424 KB
testcase_13 AC 69 ms
71,144 KB
testcase_14 AC 72 ms
75,700 KB
testcase_15 AC 71 ms
75,960 KB
testcase_16 AC 69 ms
71,356 KB
testcase_17 AC 71 ms
75,828 KB
testcase_18 AC 156 ms
101,336 KB
testcase_19 AC 155 ms
102,000 KB
testcase_20 AC 156 ms
101,416 KB
testcase_21 AC 155 ms
101,580 KB
testcase_22 AC 153 ms
101,488 KB
testcase_23 AC 125 ms
102,076 KB
testcase_24 AC 70 ms
71,128 KB
testcase_25 AC 68 ms
71,384 KB
testcase_26 AC 69 ms
71,372 KB
testcase_27 AC 69 ms
71,392 KB
testcase_28 AC 70 ms
71,448 KB
testcase_29 AC 72 ms
71,060 KB
testcase_30 AC 71 ms
71,252 KB
testcase_31 AC 70 ms
71,252 KB
testcase_32 AC 72 ms
71,540 KB
testcase_33 AC 70 ms
71,388 KB
testcase_34 AC 135 ms
100,840 KB
testcase_35 AC 89 ms
81,300 KB
testcase_36 AC 122 ms
97,792 KB
testcase_37 AC 119 ms
95,292 KB
testcase_38 AC 102 ms
87,432 KB
testcase_39 AC 93 ms
82,288 KB
testcase_40 AC 96 ms
84,412 KB
testcase_41 AC 87 ms
79,104 KB
testcase_42 AC 114 ms
93,420 KB
testcase_43 AC 119 ms
95,928 KB
testcase_44 AC 192 ms
104,724 KB
testcase_45 AC 219 ms
104,804 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:
    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