結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-27 17:59:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 668 bytes |
| コンパイル時間 | 399 ms |
| コンパイル使用メモリ | 82,212 KB |
| 実行使用メモリ | 106,468 KB |
| 最終ジャッジ日時 | 2025-07-27 18:00:01 |
| 合計ジャッジ時間 | 5,835 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 WA * 5 |
ソースコード
## https://yukicoder.me/problems/no/1443
import heapq
def main():
N, M, P = map(int, input().split())
A = list(map(int, input().split()))
max_a = max(A)
answer = float("inf")
for a in A:
a1 = a
x = 0
while a1 % P == 0:
x += 1
a1 //= P
if a <= M and a1 == 1:
continue
y = 1
cost = 0
while y * max_a <= M and y * a <= M:
y *= a1
cost += 1 + x
answer = min(answer, cost + 1)
if answer == float("inf"):
print(-1)
else:
print(answer)
if __name__ == "__main__":
main()