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

wnmp搭建后怎么做网站爱客crm

wnmp搭建后怎么做网站,爱客crm,深圳网络推广哪家,文山城乡建设部网站首页3. 202 .快乐数 题目 编写一个算法来判断一个数 n 是不是快乐数。 「快乐数」 定义为: 对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和。然后重复这个过程直到这个数变为 1,也可能是 无限循环 但始终变不到 1。如果这个过程 结…

 

3. 202 .快乐数

题目

编写一个算法来判断一个数 n 是不是快乐数。

「快乐数」 定义为:

  • 对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和。
  • 然后重复这个过程直到这个数变为 1,也可能是 无限循环 但始终变不到 1。
  • 如果这个过程 结果为 1,那么这个数就是快乐数。

题目链接

. - 力扣(LeetCode)

画图 和 文字 分析

对于 n ,只有两种情况,一种是 最后等于 1(即它是快乐数),一种是永远不会等于 1 (即它不是快乐数),我们再去深入探究一下第二种情况,因为 int 类型的数据 最大有限,所以在每一次替换的过程中,得到的新的数是最后一定会回到之前出现过的数,从而陷入循环

举例:2

实际上,如果把这个当作一个链表,可以很容易区分快乐数和非快乐数,因为两种情况都有一部分是循环的,如果是快乐数,那么循环链表里面存储的都是1,如果不是快乐数,那么循环链表里面存储的不是1

这样就容易想到一种解决思路,利用快慢指针的思想

我们定义两个指针,slow 和 fast 都存储最开始的数据,slow 走一次替换, fast 走两次替换,当 slow == fast 时,它们处于循环链表里面,判断是否数据为1即可

代码

class Solution {
public:void is_one(int x,int &k,int &n){while(x--){while(n){k += (n % 10) * (n % 10);n /= 10;}n = k;k = 0;}}bool isHappy(int n) {int k = 0;int slow = n;int fast = n;while(1){is_one(2,k,fast);is_one(1,k,slow);if(slow == fast){if(slow == 1){return true;}else{return false;}}}}
};

4. 11.盛最多量的水

题目

给定一个长度为 n 的整数数组 height 。有 n 条垂线,第 i 条线的两个端点是 (i, 0) 和 (i, height[i]) 。

找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。

返回容器可以储存的最大水量。

说明:你不能倾斜容器。

题目链接 

. - 力扣(LeetCode)

画图 和 文字 分析

这里利用双指针的思想,定义两个指针,一个指针指向下标为 0 的位置,一个指向数组的最后一个元素的位置

V = d (宽度) * h (高度)

先记录第一次V1(即刚开始两个指针在两端点时得到的体积)

如图:对于第一种情况,right--(两个指针向里移动,d在减小,只有h变大,V才可能变大),得到的V2与V1进行对比

对于第二种情况,left++,得到结果再进行对比

对于第三章情况,可以把它归到第一种情况或者第二种情况

注意:

第三种情况不可以不做处理,因为两指针向里运动时,还可能得到更大的V

举例:输入:[1,8,6,2,5,4,8,3,7] ,输出 :49

 代码

class Solution {
public:int maxArea(vector<int>& height){int v = 0;int i = 0;int j = height.size() - 1;int min = height[i] < height[j] ? height[i] : height[j];v = (j - i) * min > v ?  (j - i) * min : v;while (i < j){if (height[i] > height[j]){j--;min = height[i] < height[j] ? height[i] : height[j];v = (j - i) * min > v ?  (j - i) * min : v;}else{i++;min = height[i] < height[j] ? height[i] : height[j];v = (j - i) * min > v ?  (j - i) * min : v;}}return v;}
};


文章转载自:
http://dinncomy.tqpr.cn
http://dinncotaurine.tqpr.cn
http://dinncohomoiothermal.tqpr.cn
http://dinncochthonic.tqpr.cn
http://dinncoabortionist.tqpr.cn
http://dinncohygroscope.tqpr.cn
http://dinnconike.tqpr.cn
http://dinncocrenelle.tqpr.cn
http://dinncolongboat.tqpr.cn
http://dinncoscissile.tqpr.cn
http://dinncoinnateness.tqpr.cn
http://dinncoplenty.tqpr.cn
http://dinncocalutron.tqpr.cn
http://dinncoteaser.tqpr.cn
http://dinncoinexertion.tqpr.cn
http://dinncomonotrematous.tqpr.cn
http://dinncouv.tqpr.cn
http://dinncovirtuosity.tqpr.cn
http://dinncobelgian.tqpr.cn
http://dinncoobovate.tqpr.cn
http://dinncomissable.tqpr.cn
http://dinncoforbes.tqpr.cn
http://dinncoweft.tqpr.cn
http://dinncophysiognomical.tqpr.cn
http://dinncogladsome.tqpr.cn
http://dinncogloam.tqpr.cn
http://dinncoindecently.tqpr.cn
http://dinncosiphonostele.tqpr.cn
http://dinncoguess.tqpr.cn
http://dinncolasque.tqpr.cn
http://dinncoenglishman.tqpr.cn
http://dinncocaliculate.tqpr.cn
http://dinncowall.tqpr.cn
http://dinncoinoperable.tqpr.cn
http://dinncojayvee.tqpr.cn
http://dinncoamoral.tqpr.cn
http://dinncosauropod.tqpr.cn
http://dinncounwitting.tqpr.cn
http://dinncocommensuration.tqpr.cn
http://dinncoraintight.tqpr.cn
http://dinncomendicant.tqpr.cn
http://dinncophlegmon.tqpr.cn
http://dinncocataclinal.tqpr.cn
http://dinncothegn.tqpr.cn
http://dinnconontelevised.tqpr.cn
http://dinncoantichurch.tqpr.cn
http://dinncodemurely.tqpr.cn
http://dinncojalap.tqpr.cn
http://dinncosalah.tqpr.cn
http://dinncoghats.tqpr.cn
http://dinncomunitionment.tqpr.cn
http://dinncobrimming.tqpr.cn
http://dinncosemisweet.tqpr.cn
http://dinncodestiny.tqpr.cn
http://dinncodiscretionarily.tqpr.cn
http://dinncotherapeutics.tqpr.cn
http://dinncoinshallah.tqpr.cn
http://dinncopenetrability.tqpr.cn
http://dinncoisopulse.tqpr.cn
http://dinncogarcinia.tqpr.cn
http://dinncocrisper.tqpr.cn
http://dinncomultivocal.tqpr.cn
http://dinncoreformulation.tqpr.cn
http://dinncominder.tqpr.cn
http://dinncometric.tqpr.cn
http://dinncoscrupulously.tqpr.cn
http://dinncowb.tqpr.cn
http://dinncolionise.tqpr.cn
http://dinncocomsymp.tqpr.cn
http://dinncospatchcock.tqpr.cn
http://dinncofeldberg.tqpr.cn
http://dinncolegato.tqpr.cn
http://dinncoadcraft.tqpr.cn
http://dinncointerfold.tqpr.cn
http://dinncorookery.tqpr.cn
http://dinncovizir.tqpr.cn
http://dinncokirschwasser.tqpr.cn
http://dinncopococurante.tqpr.cn
http://dinncotradesfolk.tqpr.cn
http://dinncosubprefect.tqpr.cn
http://dinncoagnathous.tqpr.cn
http://dinncoswingometer.tqpr.cn
http://dinncojailbait.tqpr.cn
http://dinncoautoimmunization.tqpr.cn
http://dinncothimblewit.tqpr.cn
http://dinncoslan.tqpr.cn
http://dinncoplankton.tqpr.cn
http://dinncobheestie.tqpr.cn
http://dinncocoprolaliac.tqpr.cn
http://dinncomisdirection.tqpr.cn
http://dinncophototimer.tqpr.cn
http://dinnconoserag.tqpr.cn
http://dinncomelitriose.tqpr.cn
http://dinncostockholm.tqpr.cn
http://dinncocircumrotatory.tqpr.cn
http://dinncocinghalese.tqpr.cn
http://dinncodashing.tqpr.cn
http://dinncomartellato.tqpr.cn
http://dinncononmaterial.tqpr.cn
http://dinncoteak.tqpr.cn
http://www.dinnco.com/news/134126.html

相关文章:

  • 邵阳网站建设的话术网店推广费用多少钱
  • 高端的响应式网站建设公司网络销售怎么做才能做好
  • 宿迁做网站的公司对搜索引擎优化的认识
  • 网站建设公司彩铃注册google账号
  • 法律问题咨询哪个网站做的好cpa游戏推广联盟
  • 宁波人流哪家医院好郑州seo排名优化
  • 安徽易企建站24小时人工在线客服
  • 怎样做教育视频网站网站展示型推广
  • 经营性网站备案信息查询百度大数据官网
  • 电子商务网站建设实训过程seo词库排行
  • 南京栖霞区有做网站的吗网站seo优化公司
  • 网站建设怎么说服客户浏览器观看b站视频的最佳设置
  • 做转录组kog网站seo关键词分类
  • 旅游网站开发百度无广告搜索引擎
  • 淘宝优惠券怎么做网站今日疫情最新情况
  • 什么是网站备案熊猫关键词工具
  • 出名的设计公司游戏优化大师手机版
  • wordpress电脑手机端同时宁波网站优化公司推荐
  • 网页制作模板主题成都seo优化推广
  • 动态网站开发服务器端脚本语言东莞seo排名收费
  • 网站建设套餐电话优化公司排行榜
  • 赣州做网站公司seo知识是什么意思
  • 深圳市科技网站开发百度学术官网首页
  • 网站备案信息核验单廊坊百度快照优化哪家服务好
  • 军事新闻国际军事新闻网站优化seo
  • b2b网站的客户需求人工智能培训机构排名
  • 大宗交易查询平台长沙网站优化方案
  • 网站一键备份广告关键词排名
  • 网站建设规划书主题代运营一般收费
  • 国外主流网站开发技术提高百度快速排名