結果

問題 No.1330 Multiply or Divide
ユーザー U SU S
提出日時 2021-01-08 21:57:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,067 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 117,728 KB
最終ジャッジ日時 2024-04-28 02:50:14
合計ジャッジ時間 6,687 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 167 ms
112,000 KB
testcase_02 WA -
testcase_03 AC 50 ms
60,160 KB
testcase_04 AC 51 ms
60,544 KB
testcase_05 AC 55 ms
60,800 KB
testcase_06 AC 90 ms
101,376 KB
testcase_07 WA -
testcase_08 AC 169 ms
116,928 KB
testcase_09 AC 172 ms
117,176 KB
testcase_10 AC 170 ms
116,960 KB
testcase_11 AC 168 ms
116,700 KB
testcase_12 AC 171 ms
116,948 KB
testcase_13 AC 149 ms
76,556 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 117 ms
76,800 KB
testcase_17 WA -
testcase_18 AC 182 ms
116,956 KB
testcase_19 AC 175 ms
117,224 KB
testcase_20 AC 174 ms
116,836 KB
testcase_21 AC 173 ms
117,072 KB
testcase_22 AC 174 ms
117,040 KB
testcase_23 WA -
testcase_24 AC 51 ms
60,160 KB
testcase_25 AC 52 ms
60,800 KB
testcase_26 WA -
testcase_27 AC 51 ms
60,544 KB
testcase_28 AC 50 ms
60,160 KB
testcase_29 AC 50 ms
60,672 KB
testcase_30 AC 51 ms
60,160 KB
testcase_31 AC 49 ms
60,800 KB
testcase_32 AC 50 ms
60,416 KB
testcase_33 AC 52 ms
60,160 KB
testcase_34 AC 146 ms
105,012 KB
testcase_35 AC 80 ms
78,848 KB
testcase_36 AC 141 ms
98,304 KB
testcase_37 AC 126 ms
95,904 KB
testcase_38 AC 100 ms
90,240 KB
testcase_39 AC 92 ms
81,152 KB
testcase_40 AC 90 ms
85,060 KB
testcase_41 AC 80 ms
74,624 KB
testcase_42 AC 128 ms
93,952 KB
testcase_43 AC 125 ms
96,124 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1

n,m,p = mp()
a = lmp()
ag = []
for i in range(n):
    if math.gcd(a[i], p) == 1 and a[i] != 1:
        ag.append((a[i],1))
    else:
        cnt = 0
        while True:
            if a[i] % p == 0:
                cnt += 1
                a[i] //= p
            else:
                break
        if a[i] != 1:
            ag.append((a[i],1+cnt))
if not ag:
    print(-1)
    exit()
d = defaultdict(lambda:0)
for i in range(len(ag)):
    d[ag[i][1]] = max(d[ag[i][1]], ag[i][0])
d = list(d.items())
stack = [(1,0)]
ans = int(1e10)
# print(d)
while stack:
    now = stack.pop()
    if now[0] >= m:
        ans = min(ans,now[1])
    else:
        for i,j in d:
            stack.append((now[0]*j, now[1]+i))
print(ans)





0