結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
wolgnik
|
| 提出日時 | 2021-01-08 22:08:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 583 bytes |
| コンパイル時間 | 482 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 105,088 KB |
| 最終ジャッジ日時 | 2024-11-16 12:22:15 |
| 合計ジャッジ時間 | 6,620 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 WA * 23 |
ソースコード
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)
wolgnik