結果

問題 No.1330 Multiply or Divide
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-09-13 13:05:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 1,372 ms
コンパイル使用メモリ 86,504 KB
実行使用メモリ 109,020 KB
最終ジャッジ日時 2023-09-13 13:05:19
合計ジャッジ時間 10,019 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
77,564 KB
testcase_01 AC 160 ms
109,020 KB
testcase_02 AC 107 ms
72,776 KB
testcase_03 AC 114 ms
77,392 KB
testcase_04 AC 113 ms
77,388 KB
testcase_05 AC 113 ms
77,536 KB
testcase_06 AC 146 ms
105,532 KB
testcase_07 AC 158 ms
107,760 KB
testcase_08 AC 190 ms
104,964 KB
testcase_09 AC 201 ms
104,872 KB
testcase_10 AC 195 ms
105,044 KB
testcase_11 AC 182 ms
104,996 KB
testcase_12 AC 192 ms
104,796 KB
testcase_13 AC 134 ms
80,340 KB
testcase_14 AC 124 ms
79,972 KB
testcase_15 AC 115 ms
77,628 KB
testcase_16 AC 131 ms
80,592 KB
testcase_17 AC 120 ms
77,428 KB
testcase_18 AC 163 ms
103,180 KB
testcase_19 AC 164 ms
102,928 KB
testcase_20 AC 163 ms
103,284 KB
testcase_21 AC 162 ms
103,128 KB
testcase_22 AC 161 ms
103,088 KB
testcase_23 AC 170 ms
102,520 KB
testcase_24 AC 106 ms
72,724 KB
testcase_25 AC 105 ms
72,716 KB
testcase_26 AC 111 ms
77,380 KB
testcase_27 AC 104 ms
72,708 KB
testcase_28 AC 106 ms
72,596 KB
testcase_29 AC 105 ms
73,104 KB
testcase_30 AC 110 ms
72,884 KB
testcase_31 AC 105 ms
72,784 KB
testcase_32 AC 107 ms
72,840 KB
testcase_33 AC 108 ms
76,548 KB
testcase_34 AC 140 ms
101,724 KB
testcase_35 AC 120 ms
82,796 KB
testcase_36 AC 140 ms
98,508 KB
testcase_37 AC 135 ms
96,088 KB
testcase_38 AC 126 ms
88,588 KB
testcase_39 AC 119 ms
83,832 KB
testcase_40 AC 127 ms
85,844 KB
testcase_41 AC 113 ms
80,604 KB
testcase_42 AC 131 ms
93,788 KB
testcase_43 AC 139 ms
96,180 KB
testcase_44 AC 145 ms
105,836 KB
testcase_45 AC 145 ms
105,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline


N,M,P = map(int,input().split())
A = list(map(int,input().split()))
C = defaultdict(int)
for a in A:
    cnt = 0
    while a%P==0:
        a //= P
        cnt += 1
    C[cnt+1] = max(C[cnt+1],a)

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

dp = [-1]*(1001)
dp[0] = 1 
f = lambda x:min(x,1000)
for k,v in C.items():
    
    for i in range(1000):
        if dp[i]==-1:
            continue
        dp[f(i+k)] = max(dp[f(i+k)],dp[i]*v)
        
for i in range(1000):
    if dp[i]*S>M:
        print(i+1)
        exit()
print(-1)
0