結果
問題 | No.1330 Multiply or Divide |
ユーザー |
![]() |
提出日時 | 2021-01-26 11:01:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 902 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,520 KB |
実行使用メモリ | 109,824 KB |
最終ジャッジ日時 | 2024-06-23 10:24:23 |
合計ジャッジ時間 | 4,663 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 WA * 5 |
ソースコード
# coding:UTF-8 import sys MOD = 10 ** 9 + 7 INF = float('inf') N, M, P = list(map(int, input().split())) # スペース区切り連続数字 A = list(map(int, input().split())) # スペース区切り連続数字 if max(A) > M: print("1") exit() B = [0] * N C = [0] * N for i in range(N): c = 1 b = A[i] while True: if b % 2 == 0: b //= 2 c += 1 else: B[i] = b C[i] = c break res = INF for i in range(N): if B[i] == 1: continue x = M // (A[i] * B[i]) if (A[i] * B[i]) * (x - 1) > M: t = C[i] * (x - 1) + 1 res = min(res, t) elif (A[i] * B[i]) * x > M: t = C[i] * x + 1 res = min(res, t) elif (A[i] * B[i]) * (x + 1) > M: t = C[i] * (x + 1) + 1 res = min(res, t) if res == INF: print("-1") else: print(res)