結果
| 問題 | No.1330 Multiply or Divide |
| コンテスト | |
| ユーザー |
wolgnik
|
| 提出日時 | 2021-01-08 22:08:13 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 583 bytes |
| 記録 | |
| コンパイル時間 | 164 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 113,536 KB |
| 最終ジャッジ日時 | 2026-05-11 18:38:19 |
| 合計ジャッジ時間 | 4,646 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 27 |
ソースコード
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