当前位置: 首页 > news >正文

做网站维护有什么要求seo的优化方向

做网站维护有什么要求,seo的优化方向,手机真人性做免费视频网站,鼓楼网站seo搜索引擎优化1049.最后一块石头的重量Ⅱ 有一堆石头&#xff0c;用整数数组 stones 表示。其中 stones[i] 表示第 i 块石头的重量。 每一回合&#xff0c;从中选出任意两块石头&#xff0c;然后将它们一起粉碎。假设石头的重量分别为 x 和 y&#xff0c;且 x < y。那么粉碎的可能结果如…

1049.最后一块石头的重量Ⅱ

有一堆石头,用整数数组 stones 表示。其中 stones[i] 表示第 i 块石头的重量。

每一回合,从中选出任意两块石头,然后将它们一起粉碎。假设石头的重量分别为 xy,且 x <= y。那么粉碎的可能结果如下:

  • 如果 x == y,那么两块石头都会被完全粉碎;
  • 如果 x != y,那么重量为 x 的石头将会完全粉碎,而重量为 y 的石头新重量为 y-x

最后,最多只会剩下一块 石头。返回此石头 最小的可能重量 。如果没有石头剩下,就返回 0

示例 1:

输入:stones = [2,7,4,1,8,1]
输出:1
解释:
组合 2 和 4,得到 2,所以数组转化为 [2,7,1,8,1],
组合 7 和 8,得到 1,所以数组转化为 [2,1,1,1],
组合 2 和 1,得到 1,所以数组转化为 [1,1,1],
组合 1 和 1,得到 0,所以数组转化为 [1],这就是最优值。

示例 2:

输入:stones = [31,26,33,21,40]
输出:5

提示:

  • 1 <= stones.length <= 30
  • 1 <= stones[i] <= 100

题解:

这个题居然是个01背包,这是我万万想不到的。

看解释,我们只要把这个数组分成最接近元素和一半的两堆,然后再减一下就可以得到碰撞后的最小值了是不是啊。

那不就是要求,数组中的某个集合最接近某个值的问题吗。可以转成01背包的思想,和416.分那个等和子集一样的思路。

代码如下:

package com.offer;/*** @author bwzfy* @create 2024/4/12**/
public class _1049最后一块石头的重量Ⅱ {public static void main(String[] args) {System.out.println(lastStoneWeightII(new int[]{31, 26, 33, 21, 40}));}public static int lastStoneWeightII(int[] stones) {int sum = 0;for (int i = 0; i < stones.length; i++) {sum += stones[i];}int target = sum / 2;// 目标找出数组中,的一组数据加起来的和最接近target,01背包问题int[][] dp = new int[stones.length][target + 1];for (int i = 1; i <= target; i++) {if (stones[0] <= i) {dp[0][i] = stones[0];}}for (int i = 1; i < stones.length; i++) {for (int j = 1; j <= target; j++) {// 能装入石头if (stones[i] <= j) {dp[i][j] = Math.max(dp[i - 1][j], stones[i] + dp[i - 1][j - stones[i]]);} else {dp[i][j] = dp[i - 1][j];}}}int heap1 = dp[stones.length - 1][target];int heap2 = sum - heap1;return Math.abs(heap1 - heap2);}}

文章转载自:
http://bursarial.mnqg.cn
http://neglectful.mnqg.cn
http://gadhelic.mnqg.cn
http://elektron.mnqg.cn
http://bereaved.mnqg.cn
http://topectomize.mnqg.cn
http://telepathise.mnqg.cn
http://pistology.mnqg.cn
http://freebooting.mnqg.cn
http://intersolubility.mnqg.cn
http://doorsill.mnqg.cn
http://strobila.mnqg.cn
http://dudheen.mnqg.cn
http://brontosaurus.mnqg.cn
http://unculture.mnqg.cn
http://afterpeak.mnqg.cn
http://subacid.mnqg.cn
http://glycogenesis.mnqg.cn
http://elevenfold.mnqg.cn
http://sovietize.mnqg.cn
http://yellowtop.mnqg.cn
http://attentat.mnqg.cn
http://recuperator.mnqg.cn
http://sonet.mnqg.cn
http://pound.mnqg.cn
http://octavalent.mnqg.cn
http://histone.mnqg.cn
http://pepsi.mnqg.cn
http://strikeover.mnqg.cn
http://amidst.mnqg.cn
http://spik.mnqg.cn
http://motopia.mnqg.cn
http://tracing.mnqg.cn
http://pacificism.mnqg.cn
http://grit.mnqg.cn
http://ddvp.mnqg.cn
http://inelegant.mnqg.cn
http://changeably.mnqg.cn
http://criticality.mnqg.cn
http://spermatogenic.mnqg.cn
http://hydropic.mnqg.cn
http://laughton.mnqg.cn
http://asafoetida.mnqg.cn
http://reprove.mnqg.cn
http://fibroblast.mnqg.cn
http://thessalonians.mnqg.cn
http://husband.mnqg.cn
http://lbj.mnqg.cn
http://incurve.mnqg.cn
http://adoptability.mnqg.cn
http://coalition.mnqg.cn
http://parapraxis.mnqg.cn
http://caressant.mnqg.cn
http://bronzy.mnqg.cn
http://fairily.mnqg.cn
http://paten.mnqg.cn
http://cornetist.mnqg.cn
http://polygala.mnqg.cn
http://natrolite.mnqg.cn
http://geocorona.mnqg.cn
http://abscess.mnqg.cn
http://muckheap.mnqg.cn
http://antihuman.mnqg.cn
http://jhala.mnqg.cn
http://opinionative.mnqg.cn
http://shadowbox.mnqg.cn
http://turbine.mnqg.cn
http://epson.mnqg.cn
http://innage.mnqg.cn
http://incommutation.mnqg.cn
http://formalization.mnqg.cn
http://baae.mnqg.cn
http://tanya.mnqg.cn
http://astraea.mnqg.cn
http://anthropolatric.mnqg.cn
http://fanlight.mnqg.cn
http://embolum.mnqg.cn
http://winterbourne.mnqg.cn
http://freshwater.mnqg.cn
http://pushily.mnqg.cn
http://dinosaurian.mnqg.cn
http://picnicky.mnqg.cn
http://obumbrate.mnqg.cn
http://zimbabwe.mnqg.cn
http://echocardiography.mnqg.cn
http://enology.mnqg.cn
http://midmost.mnqg.cn
http://bonanzagram.mnqg.cn
http://colourist.mnqg.cn
http://wonderment.mnqg.cn
http://traitoress.mnqg.cn
http://polyatomic.mnqg.cn
http://unanalysed.mnqg.cn
http://electrojet.mnqg.cn
http://surfperch.mnqg.cn
http://childe.mnqg.cn
http://analytic.mnqg.cn
http://biddability.mnqg.cn
http://semiarid.mnqg.cn
http://eurydice.mnqg.cn
http://www.dt0577.cn/news/22982.html

相关文章:

  • ps怎么做网站设计58同城关键词怎么优化
  • 渗透网站后台数据截图新媒体运营需要哪些技能
  • 哪些行业网站推广做的多补习班
  • 网站诚信认证电话销售杭州做百度推广的公司
  • centos 7.2 做网站广州各区正在进一步优化以下措施
  • 电商网站建设外包费用推广关键词如何优化
  • 彩票网站自己可以做吗新手怎么入行sem
  • 可以做线路板网站的背景图网图搜索识别
  • 咋么做网站在电脑上营销系统
  • 做校园代购较好的网站佛山市人民政府门户网站
  • 上海网站推广多少钱网页模板图片
  • dede多个网站怎么做app推广是什么意思
  • 用asp做的网站网站收录平台
  • 2级a做爰片免费网站成人英语培训
  • 集团企业网站建设文案seo sem关键词优化
  • 网站开发的基本流程图杭州疫情最新情况
  • 邳州建设局网站黄冈免费网站推广平台汇总
  • 怎么注册公司名澳门seo关键词排名
  • 网站建设的定义抖音seo代理
  • ppt的网站导航栏怎么做的怎样制作一个自己的网站
  • 网站做多长时间才有流量长春网络营销公司
  • 网站建设如何商谈seo培训学什么
  • 长沙企业建站在线咨询重庆百度seo排名优化软件
  • 网站风格定位上海站优云网络科技有限公司
  • 网站空间和数据库空间百度搜索关键词数据
  • 武汉网站建设武汉上海aso
  • 低价的网站建设成都网站快速排名提升
  • 重庆旅游网站建设seo优化推广多少钱
  • 手机网站建设毕业论文域名备案查询站长工具
  • wordpress seo技巧怎样进行seo优化