結果
問題 | No.1330 Multiply or Divide |
ユーザー |
![]() |
提出日時 | 2021-01-08 23:13:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 948 ms / 2,000 ms |
コード長 | 1,221 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 29,692 KB |
最終ジャッジ日時 | 2024-11-16 19:24:45 |
合計ジャッジ時間 | 7,669 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
import syssys.setrecursionlimit(10**6)int1 = lambda x: int(x)-1p2D = lambda x: print(*x, sep="\n")def II(): return int(sys.stdin.buffer.readline())def MI(): return map(int, sys.stdin.buffer.readline().split())def MI1(): return map(int1, sys.stdin.buffer.readline().split())def LI(): return list(map(int, sys.stdin.buffer.readline().split()))def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))def LLI(rows_number): return [LI() for _ in range(rows_number)]def BI(): return sys.stdin.buffer.readline().rstrip()def SI(): return sys.stdin.buffer.readline().rstrip().decode()# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]dij = [[(-1, 0), (1, 0)], [(0, -1), (0, 1)]]inf = 10**16# md = 998244353md = 10**9+7from collections import defaultdictn,m,p=MI()aa=LI()cc=defaultdict(int)for a in aa:k=0while a%p==0:a//=pk+=1cc[k]=max(cc[k],a)# print(cc)amx=max(aa)t=(m+amx)//amxdef chmax(i,val):if i>1000:returnif val>dp[i]:dp[i]=valdp=[-1]*1001dp[0]=1for i in range(1000):pre=dp[i]if dp[i]>=t:print(i+1)exit()if pre==-1:continuefor k,c in cc.items():chmax(i+k+1,pre*c)# print(dp)print(-1)