結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
👑 ![]() |
提出日時 | 2021-01-08 21:48:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 561 bytes |
コンパイル時間 | 322 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 648,624 KB |
最終ジャッジ日時 | 2024-11-16 11:07:17 |
合計ジャッジ時間 | 67,836 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 8 TLE * 21 MLE * 1 |
ソースコード
#================================================ from functools import lru_cache import sys input=sys.stdin.readline N,M,P=map(int,input().split()) A=list(set(map(int,input().split()))) D={} for a in A: m=1 while a%P==0: a//=P m+=1 if a>1: if a in D: D[a]=min(m,D[a]) else: D[a]=m if not D: print(-1) exit(0) inf=float("inf") @lru_cache(maxsize=10**6) def f(x): if x>M: return 0 g=inf for a,m in D.items(): g=min(g,f(x*a)+m) return g print(f(1))