結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 102 ms
118,272 KB
testcase_02 AC 42 ms
51,840 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 42 ms
51,840 KB
testcase_05 AC 44 ms
51,840 KB
testcase_06 AC 98 ms
110,976 KB
testcase_07 AC 108 ms
117,376 KB
testcase_08 AC 128 ms
111,956 KB
testcase_09 AC 127 ms
110,808 KB
testcase_10 AC 128 ms
111,704 KB
testcase_11 AC 125 ms
111,056 KB
testcase_12 AC 126 ms
111,720 KB
testcase_13 AC 42 ms
51,840 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 43 ms
52,096 KB
testcase_17 WA -
testcase_18 AC 126 ms
112,092 KB
testcase_19 AC 123 ms
111,956 KB
testcase_20 AC 124 ms
112,232 KB
testcase_21 AC 124 ms
111,956 KB
testcase_22 AC 125 ms
112,208 KB
testcase_23 WA -
testcase_24 AC 44 ms
51,840 KB
testcase_25 AC 44 ms
51,840 KB
testcase_26 WA -
testcase_27 AC 43 ms
51,584 KB
testcase_28 AC 43 ms
51,712 KB
testcase_29 AC 43 ms
51,840 KB
testcase_30 AC 43 ms
51,840 KB
testcase_31 AC 43 ms
51,840 KB
testcase_32 AC 43 ms
51,712 KB
testcase_33 AC 43 ms
51,584 KB
testcase_34 AC 101 ms
107,904 KB
testcase_35 AC 64 ms
72,448 KB
testcase_36 AC 98 ms
102,528 KB
testcase_37 AC 90 ms
97,792 KB
testcase_38 AC 76 ms
82,944 KB
testcase_39 AC 67 ms
74,624 KB
testcase_40 AC 69 ms
78,208 KB
testcase_41 AC 60 ms
68,352 KB
testcase_42 AC 86 ms
93,952 KB
testcase_43 AC 90 ms
98,560 KB
testcase_44 AC 99 ms
111,232 KB
testcase_45 AC 98 ms
111,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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