結果

問題 No.1330 Multiply or Divide
ユーザー maninimanini
提出日時 2021-01-26 11:00:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 939 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 111,340 KB
最終ジャッジ日時 2023-09-05 14:44:20
合計ジャッジ時間 9,245 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 135 ms
111,340 KB
testcase_02 WA -
testcase_03 AC 76 ms
71,548 KB
testcase_04 AC 77 ms
71,684 KB
testcase_05 AC 75 ms
71,436 KB
testcase_06 AC 117 ms
107,836 KB
testcase_07 WA -
testcase_08 AC 152 ms
103,508 KB
testcase_09 AC 156 ms
103,796 KB
testcase_10 AC 152 ms
103,544 KB
testcase_11 AC 154 ms
103,488 KB
testcase_12 AC 153 ms
103,736 KB
testcase_13 AC 77 ms
71,332 KB
testcase_14 AC 77 ms
71,252 KB
testcase_15 AC 76 ms
71,652 KB
testcase_16 AC 76 ms
71,504 KB
testcase_17 AC 77 ms
71,432 KB
testcase_18 AC 127 ms
100,644 KB
testcase_19 AC 127 ms
100,456 KB
testcase_20 AC 129 ms
100,640 KB
testcase_21 AC 134 ms
100,256 KB
testcase_22 AC 126 ms
100,352 KB
testcase_23 WA -
testcase_24 AC 76 ms
71,576 KB
testcase_25 AC 76 ms
71,444 KB
testcase_26 AC 76 ms
71,308 KB
testcase_27 AC 77 ms
71,560 KB
testcase_28 AC 78 ms
71,104 KB
testcase_29 AC 75 ms
71,380 KB
testcase_30 AC 76 ms
71,540 KB
testcase_31 AC 74 ms
71,492 KB
testcase_32 AC 78 ms
71,360 KB
testcase_33 AC 76 ms
71,548 KB
testcase_34 AC 111 ms
101,072 KB
testcase_35 AC 87 ms
80,972 KB
testcase_36 AC 106 ms
97,840 KB
testcase_37 AC 104 ms
95,148 KB
testcase_38 AC 95 ms
87,172 KB
testcase_39 AC 89 ms
82,200 KB
testcase_40 AC 91 ms
84,336 KB
testcase_41 AC 86 ms
79,008 KB
testcase_42 AC 103 ms
93,028 KB
testcase_43 AC 107 ms
95,588 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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 M == 1:
    print("0")
    exit()
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)
0