結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 135 ms
137,728 KB
testcase_02 WA -
testcase_03 AC 40 ms
51,584 KB
testcase_04 AC 40 ms
51,584 KB
testcase_05 AC 39 ms
51,968 KB
testcase_06 AC 76 ms
95,360 KB
testcase_07 AC 85 ms
101,760 KB
testcase_08 AC 163 ms
143,456 KB
testcase_09 AC 165 ms
142,692 KB
testcase_10 AC 168 ms
143,636 KB
testcase_11 AC 161 ms
142,176 KB
testcase_12 AC 164 ms
143,216 KB
testcase_13 AC 41 ms
52,224 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 41 ms
52,096 KB
testcase_17 WA -
testcase_18 AC 149 ms
143,332 KB
testcase_19 AC 146 ms
143,464 KB
testcase_20 AC 145 ms
143,780 KB
testcase_21 AC 143 ms
143,408 KB
testcase_22 AC 150 ms
143,736 KB
testcase_23 WA -
testcase_24 AC 39 ms
51,712 KB
testcase_25 AC 40 ms
51,968 KB
testcase_26 WA -
testcase_27 AC 39 ms
51,968 KB
testcase_28 AC 40 ms
51,968 KB
testcase_29 AC 39 ms
51,584 KB
testcase_30 AC 39 ms
51,968 KB
testcase_31 AC 40 ms
51,712 KB
testcase_32 AC 39 ms
52,096 KB
testcase_33 AC 40 ms
51,968 KB
testcase_34 AC 112 ms
132,480 KB
testcase_35 AC 61 ms
78,976 KB
testcase_36 AC 106 ms
124,288 KB
testcase_37 AC 100 ms
117,120 KB
testcase_38 AC 82 ms
96,128 KB
testcase_39 AC 66 ms
83,200 KB
testcase_40 AC 71 ms
88,704 KB
testcase_41 AC 57 ms
73,600 KB
testcase_42 AC 93 ms
111,488 KB
testcase_43 AC 101 ms
118,272 KB
testcase_44 AC 77 ms
95,744 KB
testcase_45 AC 76 ms
95,872 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:
        if v >= M:
            ans = 1
            continue
        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