結果

問題 No.1330 Multiply or Divide
ユーザー moharan627
提出日時 2021-01-08 22:20:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,173 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 105,344 KB
最終ジャッジ日時 2024-11-16 12:58:09
合計ジャッジ時間 6,098 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

# 入力を整数に変換して受け取る
import sys
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力の文字列を1文字ずつに分けたものの配列を受け取る
def LC(): return list(input())
# 入力の数字列を1桁ずつに分けたものの配列を受け取る
def IC():return [int(c) for c in input()]
#少ない1行のint変数に入れる様の入力.例:N, A, B = map(int, input().split())
def MI(): return map(int, input().split())
def solve():
    N,M,P = MI()
    A = LI()
    MinOpe = -1
    import math
    from math import ceil, floor
    for i in range(N):
        A_tmp = A[i]
        Multmp = 0
        while(A_tmp%P == 0):
            A_tmp = A_tmp//P
            Multmp +=1
        if(A_tmp<=1):
            continue
        Ope = floor(math.log(M, A_tmp))
        if(MinOpe == -1):
            MinOpe = Ope*(Multmp+1)+1
        else:
            if(MinOpe > Ope*(Multmp+1)+1):
                MinOpe = Ope*(Multmp+1)+1
    print(MinOpe)
    return
solve()
0