結果
問題 | No.1330 Multiply or Divide |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-08 23:43:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 552 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 237,696 KB |
最終ジャッジ日時 | 2024-11-16 18:41:46 |
合計ジャッジ時間 | 8,911 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 TLE * 1 |
ソースコード
import sysinput=sys.stdin.readlineN,M,P=map(int,input().split())A=set(map(int,input().split()))A=list(A)Max=max(A)T={}for b in A:a=bm=1while b%P==0:b//=Pm+=1if b>1 and ((b not in T) or (T[b]>m)):T[b]=mif (not T) and Max<=M:print(-1)exit(0)Memo={}def f(x):if x in Memo:return Memo[x]elif x>M:return 0elif x*Max>M:return 1X=float("inf")for b in T:m=T[b]X=min(X,f(x*b)+m)Memo[x]=Xreturn Xprint(f(1))