結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 353 ms
29,432 KB
testcase_02 AC 30 ms
10,496 KB
testcase_03 AC 31 ms
10,624 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 30 ms
10,496 KB
testcase_06 AC 142 ms
14,416 KB
testcase_07 AC 1,103 ms
30,684 KB
testcase_08 AC 363 ms
32,404 KB
testcase_09 AC 391 ms
32,536 KB
testcase_10 AC 368 ms
32,404 KB
testcase_11 AC 360 ms
32,404 KB
testcase_12 AC 363 ms
32,532 KB
testcase_13 AC 31 ms
10,624 KB
testcase_14 AC 30 ms
10,496 KB
testcase_15 AC 31 ms
10,496 KB
testcase_16 AC 31 ms
10,624 KB
testcase_17 AC 31 ms
10,624 KB
testcase_18 AC 105 ms
32,444 KB
testcase_19 AC 105 ms
32,528 KB
testcase_20 AC 106 ms
32,532 KB
testcase_21 AC 106 ms
32,408 KB
testcase_22 AC 105 ms
32,532 KB
testcase_23 AC 366 ms
32,568 KB
testcase_24 AC 31 ms
10,496 KB
testcase_25 AC 30 ms
10,624 KB
testcase_26 AC 30 ms
10,496 KB
testcase_27 AC 30 ms
10,752 KB
testcase_28 AC 29 ms
10,624 KB
testcase_29 AC 30 ms
10,752 KB
testcase_30 AC 30 ms
10,624 KB
testcase_31 AC 30 ms
10,624 KB
testcase_32 AC 30 ms
10,752 KB
testcase_33 AC 29 ms
10,496 KB
testcase_34 AC 84 ms
26,892 KB
testcase_35 AC 45 ms
15,180 KB
testcase_36 AC 78 ms
24,884 KB
testcase_37 AC 74 ms
23,540 KB
testcase_38 AC 58 ms
18,504 KB
testcase_39 AC 48 ms
16,004 KB
testcase_40 AC 52 ms
17,240 KB
testcase_41 AC 42 ms
14,112 KB
testcase_42 AC 70 ms
22,404 KB
testcase_43 AC 77 ms
24,260 KB
testcase_44 AC 1,426 ms
14,436 KB
testcase_45 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

max_A = max(A)

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

result = 10 ** 20
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 == 10 ** 20:
    print(-1)
else:
    print(result)
0