結果

問題 No.1330 Multiply or Divide
ユーザー moharan627
提出日時 2021-01-08 22:20:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,263 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 33,312 KB
最終ジャッジ日時 2024-11-16 12:58:23
合計ジャッジ時間 6,047 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

# 入力を整数に変換して受け取る
import sys
sys.setrecursionlimit(10 ** 6)#pypy3はnumpyを使えない,この行を消すこと.
# 入力を整数に変換して受け取る
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