結果

問題 No.1330 Multiply or Divide
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-08 23:15:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 143,932 KB
最終ジャッジ日時 2024-04-28 05:23:35
合計ジャッジ時間 6,053 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 145 ms
138,308 KB
testcase_02 WA -
testcase_03 AC 40 ms
52,480 KB
testcase_04 AC 39 ms
51,840 KB
testcase_05 AC 40 ms
51,712 KB
testcase_06 AC 77 ms
95,872 KB
testcase_07 AC 83 ms
101,888 KB
testcase_08 AC 165 ms
143,356 KB
testcase_09 AC 177 ms
142,820 KB
testcase_10 AC 178 ms
143,292 KB
testcase_11 AC 174 ms
142,420 KB
testcase_12 AC 181 ms
143,476 KB
testcase_13 AC 44 ms
52,224 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 42 ms
52,480 KB
testcase_17 WA -
testcase_18 AC 159 ms
143,716 KB
testcase_19 AC 159 ms
143,932 KB
testcase_20 AC 160 ms
143,716 KB
testcase_21 AC 164 ms
143,584 KB
testcase_22 AC 154 ms
143,460 KB
testcase_23 WA -
testcase_24 AC 42 ms
51,968 KB
testcase_25 AC 43 ms
51,712 KB
testcase_26 WA -
testcase_27 AC 43 ms
51,712 KB
testcase_28 AC 42 ms
52,096 KB
testcase_29 AC 42 ms
51,712 KB
testcase_30 AC 42 ms
51,712 KB
testcase_31 AC 42 ms
52,096 KB
testcase_32 AC 42 ms
51,968 KB
testcase_33 AC 42 ms
52,096 KB
testcase_34 AC 127 ms
132,480 KB
testcase_35 AC 71 ms
78,976 KB
testcase_36 AC 115 ms
124,160 KB
testcase_37 AC 107 ms
116,992 KB
testcase_38 AC 85 ms
96,128 KB
testcase_39 AC 73 ms
82,944 KB
testcase_40 AC 79 ms
88,576 KB
testcase_41 AC 63 ms
73,216 KB
testcase_42 AC 102 ms
111,360 KB
testcase_43 AC 111 ms
118,400 KB
testcase_44 AC 86 ms
95,744 KB
testcase_45 AC 83 ms
95,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, P = map(int, input().split())
A = list(map(int, input().split()))
A = set(A)

if M == 1:
    print(0)
    exit()

ok = []
ng = []
for a in A:
    if a == 1:
        continue
    if a % P == 0:
        ng.append(a)
    else:
        ok.append(a)

ans = -1

if ok:
    v = max(ok)
    ans = 0
    x = 1
    while x < M:
        x *= v
        ans += 1


if ng:
    for v in ng:
        tmp = v
        while tmp % P == 0:
            tmp //= P
        if tmp == 1:
            continue
        cnt = 0
        x = 1
        while x < M:
            if x % P == 0:
                x //= P
            else:
                x *= v
            cnt += 1
        if ans == -1:
            ans = cnt
        else:
            cnt = min(cnt, ans)

print(ans)
0