結果
| 問題 | No.1330 Multiply or Divide |
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2021-01-08 23:10:09 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 520 bytes |
| 記録 | |
| コンパイル時間 | 380 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 162,576 KB |
| 最終ジャッジ日時 | 2026-05-11 20:58:05 |
| 合計ジャッジ時間 | 5,966 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 WA * 11 |
ソースコード
import sys
input=sys.stdin.readline
N,M,P=map(int,input().split())
A=set(map(int,input().split()))
A=list(A)
Max=max(A)
T={}
for b in A:
a=b
m=1
while b%P==0:
b//=P
if b>1 and (b not in T or T[b]>m):
T[b]=m
if (not T) and Max<=M:
print(-1)
exit(0)
Memo={}
def f(x):
if x in Memo:
return Memo[x]
elif x>M:
return 0
elif x*Max>M:
return 1
X=float("inf")
for b in T:
X=min(X,f(x*b)+m)
Memo[x]=X
return X
print(f(1))
Kazun