結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 79 ms
104,152 KB
testcase_02 AC 32 ms
52,224 KB
testcase_03 AC 36 ms
59,092 KB
testcase_04 AC 35 ms
59,392 KB
testcase_05 AC 38 ms
59,392 KB
testcase_06 AC 72 ms
99,256 KB
testcase_07 WA -
testcase_08 AC 96 ms
100,048 KB
testcase_09 AC 101 ms
100,096 KB
testcase_10 AC 101 ms
100,068 KB
testcase_11 AC 94 ms
100,224 KB
testcase_12 AC 99 ms
100,028 KB
testcase_13 AC 36 ms
59,520 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 34 ms
59,264 KB
testcase_17 WA -
testcase_18 AC 82 ms
100,224 KB
testcase_19 AC 80 ms
100,224 KB
testcase_20 AC 81 ms
100,224 KB
testcase_21 AC 83 ms
100,292 KB
testcase_22 AC 85 ms
100,284 KB
testcase_23 AC 92 ms
99,320 KB
testcase_24 AC 34 ms
52,224 KB
testcase_25 AC 31 ms
52,352 KB
testcase_26 AC 35 ms
59,520 KB
testcase_27 AC 30 ms
52,352 KB
testcase_28 AC 30 ms
52,736 KB
testcase_29 AC 31 ms
52,096 KB
testcase_30 AC 30 ms
52,224 KB
testcase_31 AC 30 ms
52,352 KB
testcase_32 AC 29 ms
52,096 KB
testcase_33 AC 36 ms
59,648 KB
testcase_34 AC 62 ms
94,720 KB
testcase_35 AC 41 ms
68,864 KB
testcase_36 AC 58 ms
90,856 KB
testcase_37 AC 56 ms
87,040 KB
testcase_38 AC 48 ms
76,544 KB
testcase_39 AC 44 ms
69,760 KB
testcase_40 AC 44 ms
72,576 KB
testcase_41 AC 37 ms
65,280 KB
testcase_42 AC 54 ms
84,352 KB
testcase_43 AC 59 ms
87,808 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 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