結果
問題 | No.1330 Multiply or Divide |
ユーザー |
![]() |
提出日時 | 2021-01-08 23:19:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 815 bytes |
コンパイル時間 | 455 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 143,580 KB |
最終ジャッジ日時 | 2024-11-16 18:01:23 |
合計ジャッジ時間 | 6,031 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 WA * 7 |
ソースコード
N, M, P = map(int, input().split())A = list(map(int, input().split()))A = set(A)if M == 1:print(0)exit()ok = []ng = []for a in A:if a == 1:continueif a % P == 0:ng.append(a)else:ok.append(a)ans = -1if ok:v = max(ok)ans = 0x = 1while x < M:x *= vans += 1if ng:for v in ng:if v >= M:ans = 1continuetmp = vwhile tmp % P == 0:tmp //= Pif tmp == 1:continuecnt = 0x = 1while x < M:if x % P == 0:x //= Pelse:x *= vcnt += 1if ans == -1:ans = cntelse:cnt = min(cnt, ans)print(ans)