結果

問題 No.1330 Multiply or Divide
ユーザー tamatotamato
提出日時 2021-01-08 21:55:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 875 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 105,652 KB
最終ジャッジ日時 2024-04-28 02:48:23
合計ジャッジ時間 5,267 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
59,776 KB
testcase_01 AC 87 ms
105,652 KB
testcase_02 AC 35 ms
52,096 KB
testcase_03 AC 40 ms
59,392 KB
testcase_04 AC 39 ms
59,520 KB
testcase_05 AC 39 ms
60,160 KB
testcase_06 AC 81 ms
99,328 KB
testcase_07 WA -
testcase_08 AC 106 ms
99,840 KB
testcase_09 AC 113 ms
100,480 KB
testcase_10 AC 105 ms
100,224 KB
testcase_11 AC 105 ms
100,116 KB
testcase_12 AC 110 ms
100,352 KB
testcase_13 AC 42 ms
59,904 KB
testcase_14 AC 41 ms
61,056 KB
testcase_15 AC 41 ms
60,416 KB
testcase_16 AC 39 ms
60,288 KB
testcase_17 AC 40 ms
60,160 KB
testcase_18 AC 89 ms
100,072 KB
testcase_19 AC 88 ms
99,976 KB
testcase_20 AC 90 ms
100,480 KB
testcase_21 AC 87 ms
100,352 KB
testcase_22 AC 91 ms
99,968 KB
testcase_23 AC 96 ms
99,320 KB
testcase_24 AC 34 ms
52,480 KB
testcase_25 AC 32 ms
52,480 KB
testcase_26 AC 40 ms
60,288 KB
testcase_27 AC 32 ms
52,096 KB
testcase_28 AC 32 ms
52,480 KB
testcase_29 AC 32 ms
52,352 KB
testcase_30 AC 35 ms
52,736 KB
testcase_31 AC 36 ms
52,224 KB
testcase_32 AC 32 ms
52,352 KB
testcase_33 AC 40 ms
60,672 KB
testcase_34 AC 68 ms
94,976 KB
testcase_35 AC 43 ms
68,608 KB
testcase_36 AC 62 ms
90,496 KB
testcase_37 AC 61 ms
87,424 KB
testcase_38 AC 52 ms
76,032 KB
testcase_39 AC 46 ms
69,888 KB
testcase_40 AC 52 ms
72,440 KB
testcase_41 AC 45 ms
65,280 KB
testcase_42 AC 59 ms
83,840 KB
testcase_43 AC 62 ms
87,908 KB
testcase_44 AC 80 ms
99,328 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
inf = 10**17


def main():
    import sys
    input = sys.stdin.readline

    N, M, P = map(int, input().split())
    A = list(map(int, input().split()))

    if max(A) > M:
        print(1)
        exit()

    B = [1] * 40
    for a in A:
        cnt = 0
        aa = a
        while aa % P == 0:
            cnt += 1
            aa //= P
        B[cnt] = max(B[cnt], aa)

    dp = [[-inf] * 40 for _ in range(40)]
    dp[0][0] = 1
    ans = inf
    ma = max(A)
    for i in range(40):
        for j in range(40):
            if i != 0:
                dp[i][j] = dp[i-1][j]
            if j - i - 1 >= 0:
                dp[i][j] = max(dp[i][j], dp[i][j-i-1] * B[i])
            if dp[i][j] * ma > M:
                ans = min(ans, j+1)
    if ans != inf:
        print(ans)
    else:
        print(-1)


if __name__ == '__main__':
    main()
0