产品最大子阵

编程入门 行业动态 更新时间:2024-10-11 15:23:46
本文介绍了产品最大子阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有n个正实数的数组

和我必须找出最大的产品子阵这个给定的数组。

And I have to find out the Maximum Product Subarray for this given array.

如何实现DP解决方案的问题?

How to implement DP Solution for the problem ?

解释溶液的DP制剂

推荐答案

由于对最大的和的解决方案众所周知,您可以

Since the solution for maximal sum is known, you can

  • 计算登录每个阵列的项目到另一个数组
  • 已知的算法应用到新阵列
  • EXP 的结果就是答案。
  • compute log of each array's item into another array
  • apply the known algorithm to the new array
  • exp of the result is the answer.

(但你可以平凡调整现有算法,这已经是@ nevets的答复中提到,更换常数0(这是加中性元素)1。)

(But you can just trivially adjust the existing algorithm, which is already mentioned in @nevets's answer. Replace the constant 0 (which is additive neutral element) with 1.)

更多推荐

产品最大子阵

本文发布于:2023-11-29 04:29:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645283.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大子   产品

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!