結果

問題 No.1330 Multiply or Divide
ユーザー H3PO4H3PO4
提出日時 2021-01-08 21:42:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 428 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 27,112 KB
最終ジャッジ日時 2024-11-16 18:20:11
合計ジャッジ時間 8,553 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 44 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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