結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 82 ms
104,480 KB
testcase_02 WA -
testcase_03 AC 35 ms
59,292 KB
testcase_04 AC 39 ms
59,776 KB
testcase_05 AC 36 ms
59,384 KB
testcase_06 AC 73 ms
98,944 KB
testcase_07 WA -
testcase_08 AC 95 ms
100,164 KB
testcase_09 AC 101 ms
100,188 KB
testcase_10 AC 95 ms
100,388 KB
testcase_11 AC 97 ms
100,044 KB
testcase_12 AC 100 ms
100,472 KB
testcase_13 AC 37 ms
59,616 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 36 ms
59,776 KB
testcase_17 WA -
testcase_18 AC 79 ms
100,464 KB
testcase_19 AC 80 ms
100,304 KB
testcase_20 AC 79 ms
100,312 KB
testcase_21 AC 81 ms
100,392 KB
testcase_22 AC 81 ms
100,352 KB
testcase_23 AC 94 ms
99,632 KB
testcase_24 AC 35 ms
52,332 KB
testcase_25 AC 31 ms
53,016 KB
testcase_26 AC 38 ms
59,756 KB
testcase_27 AC 32 ms
52,480 KB
testcase_28 AC 33 ms
52,352 KB
testcase_29 AC 33 ms
52,352 KB
testcase_30 AC 30 ms
52,480 KB
testcase_31 AC 33 ms
52,352 KB
testcase_32 AC 32 ms
52,480 KB
testcase_33 AC 39 ms
59,904 KB
testcase_34 AC 63 ms
94,564 KB
testcase_35 AC 41 ms
68,392 KB
testcase_36 AC 58 ms
90,404 KB
testcase_37 AC 57 ms
87,092 KB
testcase_38 AC 50 ms
76,672 KB
testcase_39 AC 43 ms
70,528 KB
testcase_40 AC 43 ms
72,832 KB
testcase_41 AC 37 ms
65,408 KB
testcase_42 AC 53 ms
84,608 KB
testcase_43 AC 58 ms
87,936 KB
testcase_44 WA -
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 M == 1:
        print(0)
        exit()

    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
    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] > M:
                    ans = min(ans, j)
    if ans != inf:
        print(ans)
    else:
        print(-1)


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