結果

問題 No.1330 Multiply or Divide
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-08 23:14:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 143,792 KB
最終ジャッジ日時 2024-04-28 05:12:45
合計ジャッジ時間 6,137 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 119 ms
137,856 KB
testcase_02 WA -
testcase_03 AC 33 ms
52,096 KB
testcase_04 AC 33 ms
51,840 KB
testcase_05 AC 34 ms
51,584 KB
testcase_06 AC 69 ms
95,616 KB
testcase_07 AC 77 ms
101,760 KB
testcase_08 AC 132 ms
143,212 KB
testcase_09 AC 131 ms
142,320 KB
testcase_10 AC 136 ms
143,092 KB
testcase_11 AC 130 ms
142,316 KB
testcase_12 AC 130 ms
142,964 KB
testcase_13 AC 32 ms
51,712 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 32 ms
51,840 KB
testcase_17 WA -
testcase_18 AC 133 ms
143,792 KB
testcase_19 AC 130 ms
143,356 KB
testcase_20 AC 130 ms
143,160 KB
testcase_21 AC 134 ms
143,344 KB
testcase_22 AC 133 ms
143,260 KB
testcase_23 WA -
testcase_24 AC 35 ms
52,224 KB
testcase_25 AC 33 ms
51,712 KB
testcase_26 WA -
testcase_27 AC 35 ms
52,096 KB
testcase_28 AC 33 ms
51,712 KB
testcase_29 AC 33 ms
51,968 KB
testcase_30 AC 34 ms
51,968 KB
testcase_31 AC 32 ms
51,968 KB
testcase_32 AC 32 ms
52,096 KB
testcase_33 AC 32 ms
52,096 KB
testcase_34 AC 98 ms
132,224 KB
testcase_35 AC 52 ms
78,976 KB
testcase_36 AC 93 ms
124,288 KB
testcase_37 AC 87 ms
117,376 KB
testcase_38 AC 68 ms
95,616 KB
testcase_39 AC 58 ms
82,944 KB
testcase_40 AC 63 ms
88,832 KB
testcase_41 AC 47 ms
73,600 KB
testcase_42 AC 82 ms
111,872 KB
testcase_43 AC 89 ms
118,400 KB
testcase_44 AC 68 ms
95,616 KB
testcase_45 AC 65 ms
95,744 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)

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

if ng:
    ans = -1
    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)
    exit()

print(-1)
0