結果

問題 No.1330 Multiply or Divide
ユーザー H3PO4H3PO4
提出日時 2021-01-08 21:42:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 428 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 27,344 KB
最終ジャッジ日時 2024-04-28 05:42:52
合計ジャッジ時間 8,966 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 261 ms
22,876 KB
testcase_02 WA -
testcase_03 AC 29 ms
10,624 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 31 ms
10,624 KB
testcase_06 AC 134 ms
13,464 KB
testcase_07 AC 709 ms
24,260 KB
testcase_08 AC 277 ms
26,916 KB
testcase_09 AC 286 ms
26,788 KB
testcase_10 AC 270 ms
26,796 KB
testcase_11 AC 265 ms
26,532 KB
testcase_12 AC 270 ms
27,048 KB
testcase_13 AC 32 ms
10,624 KB
testcase_14 AC 33 ms
10,496 KB
testcase_15 AC 31 ms
10,624 KB
testcase_16 AC 32 ms
10,496 KB
testcase_17 AC 31 ms
10,496 KB
testcase_18 AC 243 ms
26,536 KB
testcase_19 AC 251 ms
26,920 KB
testcase_20 AC 235 ms
26,792 KB
testcase_21 AC 259 ms
26,532 KB
testcase_22 AC 243 ms
26,532 KB
testcase_23 AC 254 ms
27,344 KB
testcase_24 AC 31 ms
10,752 KB
testcase_25 AC 31 ms
10,496 KB
testcase_26 AC 31 ms
10,752 KB
testcase_27 AC 30 ms
10,624 KB
testcase_28 AC 30 ms
10,624 KB
testcase_29 AC 30 ms
10,624 KB
testcase_30 AC 32 ms
10,624 KB
testcase_31 AC 31 ms
10,496 KB
testcase_32 AC 31 ms
10,624 KB
testcase_33 AC 32 ms
10,496 KB
testcase_34 AC 199 ms
22,452 KB
testcase_35 AC 75 ms
13,736 KB
testcase_36 AC 182 ms
21,252 KB
testcase_37 AC 162 ms
20,080 KB
testcase_38 AC 106 ms
16,356 KB
testcase_39 AC 83 ms
14,552 KB
testcase_40 AC 97 ms
15,464 KB
testcase_41 AC 66 ms
13,000 KB
testcase_42 AC 148 ms
19,128 KB
testcase_43 AC 168 ms
20,888 KB
testcase_44 AC 547 ms
13,464 KB
testcase_45 AC 731 ms
13,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


def solve(a):
    x = 1
    ct = 0
    div = 1
    b = a
    while not b % P:
        div += 1
        b //= P

    if b == 1:
        return -1
    while x * a <= M:
        x *= b
        ct += div
    ct += 1
    return ct


ans = float('inf')
for a in A:
    s = solve(a)
    if s != -1:
        ans = min(ans, s)
print(ans if ans != float('inf') else -1)
0