結果

問題 No.1330 Multiply or Divide
ユーザー c-yanc-yan
提出日時 2021-01-08 22:47:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 488 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 32,784 KB
最終ジャッジ日時 2024-04-28 05:48:57
合計ジャッジ時間 10,804 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 354 ms
29,560 KB
testcase_02 AC 29 ms
10,624 KB
testcase_03 AC 29 ms
10,624 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 30 ms
10,624 KB
testcase_06 AC 144 ms
14,436 KB
testcase_07 AC 1,110 ms
30,556 KB
testcase_08 AC 361 ms
32,540 KB
testcase_09 AC 375 ms
32,720 KB
testcase_10 AC 362 ms
32,660 KB
testcase_11 AC 352 ms
32,408 KB
testcase_12 AC 359 ms
32,532 KB
testcase_13 AC 31 ms
10,880 KB
testcase_14 AC 31 ms
10,624 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 30 ms
10,752 KB
testcase_17 AC 31 ms
10,624 KB
testcase_18 AC 103 ms
32,784 KB
testcase_19 AC 105 ms
32,660 KB
testcase_20 AC 104 ms
32,784 KB
testcase_21 AC 105 ms
32,536 KB
testcase_22 AC 104 ms
32,664 KB
testcase_23 AC 359 ms
32,564 KB
testcase_24 AC 31 ms
10,752 KB
testcase_25 AC 31 ms
10,624 KB
testcase_26 AC 31 ms
10,624 KB
testcase_27 AC 31 ms
10,624 KB
testcase_28 AC 31 ms
10,624 KB
testcase_29 AC 31 ms
10,752 KB
testcase_30 AC 31 ms
10,624 KB
testcase_31 AC 30 ms
10,624 KB
testcase_32 AC 31 ms
10,624 KB
testcase_33 AC 33 ms
10,624 KB
testcase_34 AC 86 ms
26,892 KB
testcase_35 AC 48 ms
15,176 KB
testcase_36 AC 80 ms
24,912 KB
testcase_37 AC 74 ms
23,536 KB
testcase_38 AC 57 ms
18,636 KB
testcase_39 AC 49 ms
16,000 KB
testcase_40 AC 54 ms
17,496 KB
testcase_41 AC 43 ms
13,980 KB
testcase_42 AC 71 ms
22,528 KB
testcase_43 AC 76 ms
24,388 KB
testcase_44 AC 1,448 ms
14,308 KB
testcase_45 AC 1,989 ms
14,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 20

N, M, P, *A = map(int, open(0).read().split())

def f(x):
    c = 0
    while x % P == 0:
        c += 1
        x //= P
    return (x, c)

max_A = max(A)

if max_A > M:
    print(1)
    exit()

result = INF
for m, c in map(f, A):
    if m == 1:
        continue
    t = 0
    x = 1
    while True:
        t += 1
        if x * max_A > M:
            break
        t += c
        x *= m
    result = min(result, t)
if result == INF:
    print(-1)
else:
    print(result)
0