結果
問題 | No.1330 Multiply or Divide |
ユーザー |
|
提出日時 | 2025-01-20 20:44:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 798 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 119,560 KB |
最終ジャッジ日時 | 2025-01-20 20:44:50 |
合計ジャッジ時間 | 6,645 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 WA * 1 |
ソースコード
## https://yukicoder.me/problems/no/944import heapqdef main():N, M, P = map(int, input().split())A = list(map(int, input().split()))A.sort(reverse=True)p_array = []for i in range(N):a = A[i]p_cnt = 0while a % P == 0:a //= Pp_cnt += 1p_array.append((a, p_cnt))answer = float("inf")for a, p_cnt in p_array:if a > 1:ans = 0x = 1while x * A[0] <= M:x *= aans += p_cnt + 1answer = min(ans + 1, answer)if a * (P ** p_cnt) > M:answer = min(1, answer)if answer == float("inf"):print(-1)else:print(answer)if __name__ == "__main__":main()