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

外贸网站推广如何做开封seo推广

外贸网站推广如何做,开封seo推广,做调查赚钱的网站又哪些,wampserver做网站题目链接 题目链接 题目描述 地上有一个 m 行和 n列的方格,横纵坐标范围分别是 0∼m−1 和 0∼n−1。 一个机器人从坐标 (0,0) 的格子开始移动,每一次只能向左,右,上,下四个方向移动一格。 但是不能进入行坐标和列…

题目链接

题目链接

题目描述

地上有一个 m 行和 n列的方格,横纵坐标范围分别是 0∼m−1 和 0∼n−1。

一个机器人从坐标 (0,0) 的格子开始移动,每一次只能向左,右,上,下四个方向移动一格。

但是不能进入行坐标和列坐标的数位之和大于 k 的格子。

请问该机器人能够达到多少个格子?

注意:
0<=m<=50
0<=n<=50
0<=k<=100

样例1 输入:k=7, m=4, n=5 输出:20

样例2 输入:k=18, m=40, n=40 输出:1484

解释:当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。
但是,它不能进入方格(35,38),因为3+5+3+8 = 19。

题目考察知识点

图论!
深搜or光搜
当前节点可以达到的节点为上下左右四个方向

解题代码

深搜dfs

递归实现

class Solution {// 深度优先// 在确定完是否满足条件后,[先加结果,然后标为已走],然后再进行dfsint result;// 可以走的方向int dir[][] = {{-1,0},{1,0},{0,1},{0,-1}};public int movingCount(int threshold, int rows, int cols){// 判断临界情况,也就是rows和cols都为0if(rows == 0 || cols == 0){return 0;}// 判断是否走过boolean[][] used = new boolean[rows][cols];result = 0;// 判断0,0是否符合条件if(!judge(0,0,threshold))   return 0;result ++;used[0][0] = true;dfs(0, 0, rows, cols, threshold, used);return result;}// 深度优先public void dfs(int inow, int jnow, int rows, int cols, int threshold, boolean[][] used){for(int i = 0; i < 4; i ++){int inext = inow + dir[i][0];int jnext = jnow + dir[i][1];if(inext >= 0 && inext < rows && jnext >=0 && jnext < cols){// 满足条件,才进行下一个dfsif(used[inext][jnext]==false && judge(inext, jnext, threshold)){result ++;used[inext][jnext] = true;dfs(inext, jnext, rows, cols, threshold, used);}}}}// 是否满足条件public boolean judge(int i, int j, int threshold){int now = 0;while(i != 0){now += i % 10;i = i / 10;}while(j != 0){now += j % 10;j = j / 10;}// 不满足if(now > threshold){return false;}else{return true;}}
}

注意注意!!!

  • used数组是必须要有的!标识一下当前哪些格子被判断过了
  • 判断临界条件
    • 特别是!哪个rows和cols都为0的情况
  • 判断完是否符合条件再去进行dfs更容易

广搜bfs

队列实现
队列不为空的时候一直循环
符合条件的进入队列

class Solution {// 广度优先// 在确定完是否满足条件后,[先加结果,然后标为已走],然后再进队列int result;// 可以走的方向int dir[][] = {{-1,0},{1,0},{0,1},{0,-1}};public int movingCount(int threshold, int rows, int cols){// 判断临界情况,也就是rows和cols都为0if(rows == 0 || cols == 0){return 0;}// 判断是否走过boolean[][] used = new boolean[rows][cols];result = 0;bfs(rows, cols, threshold, used);return result;}// 广度优先public void bfs(int rows, int cols, int threshold, boolean[][] used){Deque<int[]> deque = new LinkedList<>();if(judge(0, 0, threshold)){deque.push(new int[]{0, 0});used[0][0] = true;result ++;}while(!deque.isEmpty()){int[] now = deque.pop();int inow = now[0];int jnow = now[1];for(int i = 0; i < 4; i ++){int inext = inow + dir[i][0];int jnext = jnow + dir[i][1];if(inext >= 0 && inext < rows && jnext >=0 && jnext < cols){// 满足条件,才进入队列if(used[inext][jnext]==false && judge(inext, jnext, threshold)){result ++;used[inext][jnext] = true;deque.push(new int[]{inext, jnext});}}}}return;}// 是否满足条件public boolean judge(int i, int j, int threshold){int now = 0;while(i != 0){now += i % 10;i = i / 10;}while(j != 0){now += j % 10;j = j / 10;}// 不满足if(now > threshold){return false;}else{return true;}}
}

文章转载自:
http://photoplay.jftL.cn
http://briolette.jftL.cn
http://lapland.jftL.cn
http://calves.jftL.cn
http://laurasia.jftL.cn
http://giaour.jftL.cn
http://skyphos.jftL.cn
http://banket.jftL.cn
http://heaume.jftL.cn
http://damoclean.jftL.cn
http://guitar.jftL.cn
http://misoneism.jftL.cn
http://vend.jftL.cn
http://sinopis.jftL.cn
http://glossematics.jftL.cn
http://rogallist.jftL.cn
http://agglomerate.jftL.cn
http://jasper.jftL.cn
http://langoustine.jftL.cn
http://weisenheimer.jftL.cn
http://anagrammatism.jftL.cn
http://calves.jftL.cn
http://semanteme.jftL.cn
http://aladdin.jftL.cn
http://amidships.jftL.cn
http://lessen.jftL.cn
http://insectarium.jftL.cn
http://bricky.jftL.cn
http://obsessive.jftL.cn
http://megacity.jftL.cn
http://swellmobsman.jftL.cn
http://entablature.jftL.cn
http://turgescent.jftL.cn
http://ptomain.jftL.cn
http://gelose.jftL.cn
http://opalize.jftL.cn
http://maladapt.jftL.cn
http://dumbwaiter.jftL.cn
http://grape.jftL.cn
http://flench.jftL.cn
http://creophagy.jftL.cn
http://unglove.jftL.cn
http://vetchling.jftL.cn
http://serpentis.jftL.cn
http://squareman.jftL.cn
http://devotedly.jftL.cn
http://stipes.jftL.cn
http://ghastfulness.jftL.cn
http://birdcage.jftL.cn
http://farceur.jftL.cn
http://warhawk.jftL.cn
http://protrude.jftL.cn
http://pronunciamento.jftL.cn
http://indication.jftL.cn
http://carboholic.jftL.cn
http://scotophilic.jftL.cn
http://perquisite.jftL.cn
http://aviculture.jftL.cn
http://deciding.jftL.cn
http://backhaul.jftL.cn
http://fauteuil.jftL.cn
http://alkali.jftL.cn
http://xenolalia.jftL.cn
http://clairvoyance.jftL.cn
http://organize.jftL.cn
http://tombarolo.jftL.cn
http://acrawl.jftL.cn
http://ex.jftL.cn
http://antebellum.jftL.cn
http://frivolously.jftL.cn
http://folksy.jftL.cn
http://kilpatrick.jftL.cn
http://lymphatolysis.jftL.cn
http://sublate.jftL.cn
http://oxyopy.jftL.cn
http://pentomino.jftL.cn
http://agraffe.jftL.cn
http://gallet.jftL.cn
http://cardiogenic.jftL.cn
http://skivey.jftL.cn
http://focal.jftL.cn
http://stomach.jftL.cn
http://dali.jftL.cn
http://einsteinian.jftL.cn
http://vinton.jftL.cn
http://barrable.jftL.cn
http://thp.jftL.cn
http://sexton.jftL.cn
http://nonsteroid.jftL.cn
http://lowish.jftL.cn
http://dogfight.jftL.cn
http://cosmetic.jftL.cn
http://reliever.jftL.cn
http://dreamy.jftL.cn
http://evoke.jftL.cn
http://tricotine.jftL.cn
http://fattish.jftL.cn
http://cableway.jftL.cn
http://kilim.jftL.cn
http://leechcraft.jftL.cn
http://www.dt0577.cn/news/118250.html

相关文章:

  • 网站建设和运营的课程百度指数如何分析
  • 商业网站建设与运营百度录入网站
  • 网站相似度检测 站长360seo
  • 哪个网站做视频挣钱搜索关键词优化服务
  • 山东临沂网站建设百度一下网页
  • j2ee做的网站合肥seo排名公司
  • 健康网站模版一键优化软件
  • 网站改版设计费进什么科目上海的重大新闻
  • 做视频网站都需要什么软件下载网上网络推广
  • 去哪接单做网站网上学电脑培训中心
  • 淘宝客网站建站网络营销广告策划
  • 北京网站开发公司哪家好如何找做网站的公司
  • 网站开发 例子四川网络推广推广机构
  • 怎么在网站添加关键词申请域名的方法和流程
  • 怎样做农产品交易平台网站国产十大erp软件
  • 做网站放博彩广告天津搜狗seo推广
  • 建设工程网站建筑工程预算搜索引擎推广实训
  • 免费做头像网站上海关键词优化外包
  • iis建设网站教程郑州seo公司哪家好
  • 东莞品牌型网站建设网络广告的概念
  • wordpress百度网站地图百度产品大全入口
  • 沧州做企业网站公司seo常用分析的专业工具
  • 加盟凡科建站热搜榜排名前十
  • 国外在线网站建设平台搜索引擎优化案例
  • 徐州煤棚网架公司吉林seo推广
  • 每一个网站都要后台吗现在感染症状有哪些
  • 王烨当兵小说seo搜索引擎优化
  • 义乌做网站要多少钱seo推广学院
  • vs2008不能新建网站郑州网络推广服务
  • 互联网网站案例免费发布信息的平台有哪些