結果

問題 No.1330 Multiply or Divide
ユーザー tamatotamato
提出日時 2021-01-08 21:47:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 105,472 KB
最終ジャッジ日時 2024-04-28 02:37:52
合計ジャッジ時間 4,528 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
59,008 KB
testcase_01 AC 91 ms
104,576 KB
testcase_02 AC 37 ms
52,480 KB
testcase_03 AC 39 ms
59,008 KB
testcase_04 AC 38 ms
59,264 KB
testcase_05 AC 39 ms
59,136 KB
testcase_06 AC 80 ms
98,560 KB
testcase_07 WA -
testcase_08 AC 107 ms
100,352 KB
testcase_09 AC 118 ms
100,096 KB
testcase_10 AC 105 ms
100,072 KB
testcase_11 AC 105 ms
100,348 KB
testcase_12 AC 112 ms
100,216 KB
testcase_13 AC 41 ms
59,264 KB
testcase_14 AC 41 ms
60,032 KB
testcase_15 AC 41 ms
60,160 KB
testcase_16 AC 39 ms
59,520 KB
testcase_17 AC 39 ms
59,904 KB
testcase_18 AC 91 ms
100,096 KB
testcase_19 AC 90 ms
100,108 KB
testcase_20 AC 98 ms
100,036 KB
testcase_21 AC 90 ms
100,320 KB
testcase_22 AC 90 ms
100,212 KB
testcase_23 AC 97 ms
99,376 KB
testcase_24 AC 33 ms
51,968 KB
testcase_25 AC 33 ms
52,224 KB
testcase_26 AC 39 ms
59,904 KB
testcase_27 AC 33 ms
52,096 KB
testcase_28 AC 33 ms
52,352 KB
testcase_29 AC 32 ms
52,224 KB
testcase_30 AC 34 ms
52,224 KB
testcase_31 AC 32 ms
52,096 KB
testcase_32 AC 33 ms
52,224 KB
testcase_33 AC 41 ms
59,904 KB
testcase_34 AC 71 ms
94,592 KB
testcase_35 AC 50 ms
68,480 KB
testcase_36 AC 69 ms
90,496 KB
testcase_37 AC 65 ms
87,040 KB
testcase_38 AC 56 ms
76,160 KB
testcase_39 AC 49 ms
69,632 KB
testcase_40 AC 50 ms
72,576 KB
testcase_41 AC 44 ms
65,536 KB
testcase_42 AC 63 ms
84,224 KB
testcase_43 AC 68 ms
87,608 KB
testcase_44 AC 82 ms
98,688 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