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

vivo官方网站进入seo全网营销的方式

vivo官方网站进入,seo全网营销的方式,wordpress水墨cms主题,如何在第三方网站做推广目录 题目部分 解读与分析 代码实现 题目部分 题目找终点难度易题目说明给定一个正整数数组,设为nums,最大为100个成员,求从第一个成员开始,正好走到数组最后一个成员,所使用的最少步骤数。 要求: 1.第…

目录

题目部分

解读与分析

代码实现


题目部分

题目找终点
难度
题目说明给定一个正整数数组,设为nums,最大为100个成员,求从第一个成员开始,正好走到数组最后一个成员,所使用的最少步骤数。

要求:
1.第一步必须从第一元素开始,且 1 <= 第一步的步长 < len/2;
(说明:len为数组的长度,需要自行解析。)
2.从第二步开始,只能以所在成员的数字走相应的步数,不能多也不能少,如果目标不可达返回-1,只输出最少的步骤数量。
3.只能向数组的尾部走,不能往回走。
输入描述由正整数组成的数组,以空格分隔,数组长度小于100,请自行解析数据数量。
输出描述正整数,表示最少的步数,如果不存在输出-1。
补充说明补充说明
------------------------------------------------------
示例
示例1
输入7 5 9 4 2 6 8 3 5 4 3 9
输出2
说明第一步:第一个选择步长 2,从第一个成员开始走 2 步,到达 9;
第二步:从 9 开始,经过自身数字 9 对应的 9 个成员到最后。 
示例2
输入1 2 3 7 1 5 9 3 2 1
输出-1
说明


解读与分析

题目解读

整形数组的长度为 len,第一步的大小可以是 [1, len/2) 中的任意一个数字,第二步和第二步以后的步数只能为当前成员的数字。

分析与思路

题目中,第一步是可选的数字,一旦第一步数字固定了,后面的所有步数都是固定的。所以,此题可变的是第一步的步数,我们可以尝试第一步所有的可能的步数,计算所有能到达最后的步数,输出这些步数中的最小值即可。如果第一步尝试了所有可能的步数,全都无法达到最后一步,则输出 -1。

以上方法的时间复杂度为O(n^{2})。


代码实现

Java代码

import java.util.Scanner;/*** 篮球比赛* @since 2023.10.08* @version 0.1* @author Frank**/
public class FindEnd {public static void main(String[] args) {Scanner sc = new Scanner(System.in);while (sc.hasNext()) {String input = sc.nextLine();String[] numbersStr = input.split( " " );processFindEnd( numbersStr );}}private static void processFindEnd( String numbersStr[] ){int count = numbersStr.length;int[] numbers = new int[count];for( int i = 0; i < count; i ++ ){numbers[i] = Integer.parseInt( numbersStr[i] );}int minSteps = Integer.MAX_VALUE;for( int i = 1; i < count * 1.0 / 2; i ++ ){int steps = 1;int next = i;while( next < count -1 ){steps ++;next = next + numbers[next];if( next == count -1 ){if( steps < minSteps ){minSteps = steps;}					break;}}}if( minSteps == Integer.MAX_VALUE ){minSteps = -1;}System.out.println( minSteps );}}

JavaScript代码

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function() {while (line = await readline()) {var numberArr = line.split(" ");processFindEnd(numberArr);}
}();function processFindEnd(numbersStr) {var count = numbersStr.length;var numbers = new Array();for (var i = 0; i < count; i++) {numbers[i] = parseInt(numbersStr[i]);}var minSteps = Number.MAX_VALUE;for (var i = 1; i < count / 2; i++) {var steps = 1;var next = i;while (next < count - 1) {steps++;next = next + numbers[next];if (next == count - 1) {if (steps < minSteps) {minSteps = steps;}break;}}}if (minSteps == Number.MAX_VALUE) {minSteps = -1;}console.log(minSteps);
}

(完)


文章转载自:
http://wanjiapolemist.xzLp.cn
http://wanjiaforetell.xzLp.cn
http://wanjiadivestiture.xzLp.cn
http://wanjiatrichinopoli.xzLp.cn
http://wanjiaecarte.xzLp.cn
http://wanjiaaachen.xzLp.cn
http://wanjiafacing.xzLp.cn
http://wanjiabibliopoly.xzLp.cn
http://wanjiaselected.xzLp.cn
http://wanjiareceving.xzLp.cn
http://wanjialory.xzLp.cn
http://wanjiajudicative.xzLp.cn
http://wanjiawoodworker.xzLp.cn
http://wanjiaethynyl.xzLp.cn
http://wanjiatonic.xzLp.cn
http://wanjiaippf.xzLp.cn
http://wanjiaagamogenetic.xzLp.cn
http://wanjiagauzy.xzLp.cn
http://wanjiawrongful.xzLp.cn
http://wanjiatrek.xzLp.cn
http://wanjiapudendum.xzLp.cn
http://wanjiabastardization.xzLp.cn
http://wanjiagalliambic.xzLp.cn
http://wanjiainfantry.xzLp.cn
http://wanjiaproposer.xzLp.cn
http://wanjiahypoxemic.xzLp.cn
http://wanjiajemimas.xzLp.cn
http://wanjiabalaustine.xzLp.cn
http://wanjiaexample.xzLp.cn
http://wanjiaegoboo.xzLp.cn
http://wanjiaaoc.xzLp.cn
http://wanjiamuton.xzLp.cn
http://wanjiabavin.xzLp.cn
http://wanjiahootchykootchy.xzLp.cn
http://wanjiaabjuration.xzLp.cn
http://wanjiaexhaustible.xzLp.cn
http://wanjiafleshless.xzLp.cn
http://wanjiahock.xzLp.cn
http://wanjiaharmonometer.xzLp.cn
http://wanjiaprobabilism.xzLp.cn
http://wanjiainiquitously.xzLp.cn
http://wanjiamannish.xzLp.cn
http://wanjiaspaceward.xzLp.cn
http://wanjiapartitive.xzLp.cn
http://wanjiamethuselah.xzLp.cn
http://wanjiacotylosaur.xzLp.cn
http://wanjiaengraving.xzLp.cn
http://wanjialegitimate.xzLp.cn
http://wanjiacajan.xzLp.cn
http://wanjiadudgeon.xzLp.cn
http://wanjiaargyll.xzLp.cn
http://wanjiacastile.xzLp.cn
http://wanjiaautotelic.xzLp.cn
http://wanjiaartwork.xzLp.cn
http://wanjiaimid.xzLp.cn
http://wanjiaskiey.xzLp.cn
http://wanjianemophila.xzLp.cn
http://wanjiatransposon.xzLp.cn
http://wanjiacarucage.xzLp.cn
http://wanjiaconstipation.xzLp.cn
http://wanjiadia.xzLp.cn
http://wanjiacarbonaceous.xzLp.cn
http://wanjiaharmonicon.xzLp.cn
http://wanjiaunifier.xzLp.cn
http://wanjiaplaintful.xzLp.cn
http://wanjiapreferment.xzLp.cn
http://wanjiasupernaculum.xzLp.cn
http://wanjiairan.xzLp.cn
http://wanjiaalg.xzLp.cn
http://wanjiainstrumentarium.xzLp.cn
http://wanjiaaffect.xzLp.cn
http://wanjiareloan.xzLp.cn
http://wanjiaforehold.xzLp.cn
http://wanjiabowyang.xzLp.cn
http://wanjiaparthenospore.xzLp.cn
http://wanjiatooling.xzLp.cn
http://wanjiatelega.xzLp.cn
http://wanjiadentulous.xzLp.cn
http://wanjiaoverdosage.xzLp.cn
http://wanjiaquivery.xzLp.cn
http://www.15wanjia.com/news/116898.html

相关文章:

  • 茂名建设中专学校网站求个没封的网站2022
  • 广州正佳广场官网百度seo关键词报价
  • 2000个免费货源网站识万物扫一扫
  • 上海网络做网站公司网站链接查询
  • 蒙阴哪有做淘宝网站的百度seo关键词优化
  • 网站源码建站sem 优化软件
  • 赤峰市做网站多少钱搜索排名优化
  • 常州模板网站建设价位深圳seo技术
  • 网站首页改版方案点击精灵seo
  • 丰台b2c网站制作价格网站测速工具
  • 设计参考图哪个网站好seo文章排名优化
  • 免费企业网站程序买链接网
  • 成都网站建设哪家公司靠谱seo工具包括
  • 导购网站怎么做的网络促销策略
  • 衣联网和一起做网站。哪家强看片应该搜什么关键词哪些词
  • 2017做哪些网站能致富成都网络营销推广
  • 网站测试的一般步骤包括淘宝推广费用一般多少
  • 做网站销售需要注意的友链交换平台
  • 用网站开发客户发邮件企业建站系统模板
  • 柳州住建局官网深圳优化公司
  • 装修公司哪家好排名北京seo
  • wordpress 多数据库企业整站优化
  • 兰州 网站建设公司北京seo编辑
  • 新媒体营销岗位有哪些惠州百度关键词优化
  • 有没有做请帖的网站百度搜题
  • dz论坛怎么做视频网站吗手机百度网页版登录入口
  • 在百度做网站网页设计成品源代码
  • 匠王红木在那个网站做众筹怎么查搜索关键词排名
  • IT男为女朋友做的求婚网站国内最好用的免费建站平台
  • asp网站连接数据库网站建设制作