結果

問題 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
コンパイル時間 784 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 24,196 KB
最終ジャッジ日時 2023-08-10 12:25:53
合計ジャッジ時間 8,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 203 ms
23,536 KB
testcase_02 WA -
testcase_03 AC 15 ms
7,780 KB
testcase_04 AC 15 ms
7,800 KB
testcase_05 AC 16 ms
7,944 KB
testcase_06 AC 108 ms
9,996 KB
testcase_07 AC 613 ms
23,352 KB
testcase_08 AC 217 ms
24,064 KB
testcase_09 AC 226 ms
24,196 KB
testcase_10 AC 214 ms
24,084 KB
testcase_11 AC 210 ms
23,852 KB
testcase_12 AC 216 ms
24,076 KB
testcase_13 AC 15 ms
7,792 KB
testcase_14 AC 15 ms
7,796 KB
testcase_15 AC 14 ms
7,864 KB
testcase_16 AC 15 ms
7,856 KB
testcase_17 AC 15 ms
7,900 KB
testcase_18 AC 193 ms
23,900 KB
testcase_19 AC 198 ms
24,076 KB
testcase_20 AC 190 ms
24,132 KB
testcase_21 AC 206 ms
23,928 KB
testcase_22 AC 196 ms
23,904 KB
testcase_23 AC 209 ms
24,148 KB
testcase_24 AC 15 ms
7,848 KB
testcase_25 AC 15 ms
7,788 KB
testcase_26 AC 15 ms
7,752 KB
testcase_27 AC 15 ms
7,812 KB
testcase_28 AC 15 ms
7,904 KB
testcase_29 AC 15 ms
7,844 KB
testcase_30 AC 15 ms
7,848 KB
testcase_31 AC 15 ms
7,848 KB
testcase_32 AC 15 ms
7,792 KB
testcase_33 AC 15 ms
7,900 KB
testcase_34 AC 157 ms
20,124 KB
testcase_35 AC 53 ms
11,296 KB
testcase_36 AC 140 ms
18,448 KB
testcase_37 AC 127 ms
17,304 KB
testcase_38 AC 80 ms
13,988 KB
testcase_39 AC 61 ms
12,156 KB
testcase_40 AC 73 ms
12,832 KB
testcase_41 AC 44 ms
10,440 KB
testcase_42 AC 114 ms
16,680 KB
testcase_43 AC 134 ms
18,096 KB
testcase_44 AC 458 ms
9,968 KB
testcase_45 AC 582 ms
10,128 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