結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 106 ms
118,016 KB
testcase_02 WA -
testcase_03 AC 41 ms
51,584 KB
testcase_04 AC 40 ms
51,584 KB
testcase_05 AC 41 ms
51,968 KB
testcase_06 AC 94 ms
110,976 KB
testcase_07 AC 104 ms
117,120 KB
testcase_08 AC 123 ms
111,724 KB
testcase_09 AC 124 ms
111,080 KB
testcase_10 AC 124 ms
111,716 KB
testcase_11 AC 121 ms
110,764 KB
testcase_12 AC 121 ms
111,668 KB
testcase_13 AC 41 ms
51,584 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 42 ms
51,968 KB
testcase_17 WA -
testcase_18 AC 119 ms
112,224 KB
testcase_19 AC 120 ms
112,240 KB
testcase_20 AC 120 ms
112,368 KB
testcase_21 AC 121 ms
112,356 KB
testcase_22 AC 121 ms
112,352 KB
testcase_23 WA -
testcase_24 AC 41 ms
51,840 KB
testcase_25 AC 48 ms
51,968 KB
testcase_26 WA -
testcase_27 AC 41 ms
51,968 KB
testcase_28 AC 40 ms
51,584 KB
testcase_29 AC 41 ms
51,712 KB
testcase_30 AC 42 ms
51,968 KB
testcase_31 AC 41 ms
51,712 KB
testcase_32 AC 47 ms
51,840 KB
testcase_33 AC 41 ms
51,712 KB
testcase_34 AC 97 ms
108,544 KB
testcase_35 AC 61 ms
72,320 KB
testcase_36 AC 93 ms
102,656 KB
testcase_37 AC 87 ms
97,792 KB
testcase_38 AC 72 ms
83,200 KB
testcase_39 AC 64 ms
74,368 KB
testcase_40 AC 68 ms
78,208 KB
testcase_41 AC 57 ms
68,352 KB
testcase_42 AC 84 ms
93,952 KB
testcase_43 AC 87 ms
99,200 KB
testcase_44 AC 96 ms
111,360 KB
testcase_45 AC 96 ms
111,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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:
    v = max(ng)
    if v >= M:
        print(1)
        exit()
    tmp = v
    while tmp % P == 0:
        tmp //= P
    if tmp == 1:
        print(-1)
        exit()
    ans = 0
    x = 1
    while x < M:
        if x % P == 0:
            x //= P
        else:
            x *= v
        ans += 1
    print(ans)
    exit()

print(-1)
0