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

白云网站 建设信科网络sem竞价专员

白云网站 建设信科网络,sem竞价专员,日本 女做视频网站,湖南做网站 尖端磐石网络写在前面 自己玩了很多项目,但是最近准备秋招的过程中,发现自己对于算法和编程语言的基本功夫实在是太欠缺了。 投递了华为的实习岗位,4.26参加机考,一做题就发现了自己很多地方都不会。这里写下笔试后的复盘以警醒自己。 题目 …

写在前面

自己玩了很多项目,但是最近准备秋招的过程中,发现自己对于算法和编程语言的基本功夫实在是太欠缺了。
投递了华为的实习岗位,4.26参加机考,一做题就发现了自己很多地方都不会。这里写下笔试后的复盘以警醒自己。

题目

按照记忆来回顾题目,仅供参考。解法为自己复盘所写,没有经过数据集测试,不保真。
如果有发现问题,欢迎提出,非常感谢!
机考第一题,分值(100分)

题目描述

在n*n的矩阵范围内,有K个配送站和N个客户点,配送点和客户的坐标给出。如何计算最短路径让K个配送点能够全部覆盖N个客户点。配送站和客户点的距离表示如:distance = |x1-x2| + |y1 - y2|

解题思路

复盘的时候,理解到这道题是一个匹配问题。
解题思路如下:

  • 先建立配送站和客户点的位置地图。地图大小是n*n矩阵,并将配送站和客户点的位置存储。
  • 求出所有配送站与客户的距离distance_all[K][N],并在计算的过程中记录最大距离max_distance。下图中D[K][N]表示第K的配送点和第N的客户的距离
    在这里插入图片描述
  • 然后开始从0到max_distance开始循环,每次循环的值为distance,再对距离数组先从上到下遍历,再从左到右遍历。
  • 如果在该列中存在D小于distance,那么代表有一个配送站能到达此客户点,那么跳出此列,进入下一列,直至遍历所有列。如果有一列不存在D小于distance,说明有一个客户点没有配送站能到达,那么跳出行遍历,distance++
  • 由于一定存在一个distance能够满足要求,因此无需考虑不存在distance的情况。如果行列遍历均结束,则跳出distance循环,并输出当前distance
    在这里插入图片描述

代码

因为是笔试后复盘,未经过数据集检验。解法也不一定是最优解。如果有问题或者别的思路,欢迎提出。

#include <stdio.h>      
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{int R,C;scanf("%d %d", &R, &C);                             //扫描矩阵范围行*列:R*C//printf("%d", R);int people_num;scanf("%d", &people_num);                           //扫描客户数量//printf("%d", people_num);int R_location[people_num],C_location[people_num];  //初始化地图矩阵for(int i=0; i<people_num; i++){scanf("%d %d", &R_location[i],&C_location[i]);  //获得客户的地址//printf("\n%d %d\n", R_location[i],C_location[i]);}int send;scanf("%d", &send);                                 //配送站的数量int R_send[send],C_send[send];int distance_all[send][people_num];                 //配送站到客户的距离for(int i=0; i<send; i++){scanf("%d %d", &R_send[i],&C_send[i]);          //配送站的地址//printf("\n%d %d\n", R_send[i],C_send[i]);}//计算每个配送站到客户的距离并存储到distance_all中,并存储最大距离int max_distance=0;for(int i=0; i<send; i++){for(int j=0; j<people_num; j++){                distance_all[i][j] = abs(R_send[i]-R_location[j]) + abs(C_send[i] - C_location[j]);if(distance_all[i][j] > max_distance)max_distance = distance_all[i][j];printf("%d ",distance_all[i][j]);}}printf("\n");//从最短配送距离0到最长配送距离max_distance,因为最大的可能就是max_distanceint distance = 0,i=0,j=0;for(distance = 0; distance<=max_distance; distance++){for(i=0; i<people_num; i++){for(j=0; j<send; j++){                if(distance_all[j][i] <= distance)break;//printf("%d ",distance_all[i][j]);}if(j >= send)   //如果配送站到某一个用户距离比当前距离大,说明该用户无法被配送到,距离更新break;}if(i >= people_num) //如果有一个距离满足了所有用户都至少有一个配送站能到,说明该距离已经符号break;}printf("%d",distance);return 0;
}

文章转载自:
http://dinncoprofessionless.tqpr.cn
http://dinncoindecorum.tqpr.cn
http://dinncocalculational.tqpr.cn
http://dinncoairman.tqpr.cn
http://dinncotombstone.tqpr.cn
http://dinncoconditionality.tqpr.cn
http://dinnconiaiserie.tqpr.cn
http://dinncocowrie.tqpr.cn
http://dinncosamarang.tqpr.cn
http://dinnconeuroma.tqpr.cn
http://dinncoallergin.tqpr.cn
http://dinncomuggee.tqpr.cn
http://dinncoovertax.tqpr.cn
http://dinncopolypary.tqpr.cn
http://dinncofaggoting.tqpr.cn
http://dinncorestiform.tqpr.cn
http://dinncosafranin.tqpr.cn
http://dinncooverzealous.tqpr.cn
http://dinncowithstand.tqpr.cn
http://dinncoesotropia.tqpr.cn
http://dinncocatholicness.tqpr.cn
http://dinncoutilidor.tqpr.cn
http://dinncospermalege.tqpr.cn
http://dinncoconfesser.tqpr.cn
http://dinncocaducei.tqpr.cn
http://dinncopatinize.tqpr.cn
http://dinncoreembarkation.tqpr.cn
http://dinncolaunch.tqpr.cn
http://dinncoknavish.tqpr.cn
http://dinncoprovided.tqpr.cn
http://dinncozinger.tqpr.cn
http://dinncoincumbrance.tqpr.cn
http://dinncohelen.tqpr.cn
http://dinncointerfluent.tqpr.cn
http://dinncooffaly.tqpr.cn
http://dinncoscalp.tqpr.cn
http://dinncosphenography.tqpr.cn
http://dinncounascertainable.tqpr.cn
http://dinncobreccia.tqpr.cn
http://dinncounenthralled.tqpr.cn
http://dinncoturmoil.tqpr.cn
http://dinncodandy.tqpr.cn
http://dinncopentatonism.tqpr.cn
http://dinncoproportionately.tqpr.cn
http://dinncocuchifrito.tqpr.cn
http://dinncoamanuensis.tqpr.cn
http://dinncohoropter.tqpr.cn
http://dinncocouch.tqpr.cn
http://dinncofinder.tqpr.cn
http://dinncomethacetin.tqpr.cn
http://dinncorumbullion.tqpr.cn
http://dinncopareira.tqpr.cn
http://dinncohomochromy.tqpr.cn
http://dinncogulosity.tqpr.cn
http://dinncoserai.tqpr.cn
http://dinncolumberyard.tqpr.cn
http://dinncorepetitiousness.tqpr.cn
http://dinncoblush.tqpr.cn
http://dinncoinvolved.tqpr.cn
http://dinncouphove.tqpr.cn
http://dinncoantidiuresis.tqpr.cn
http://dinncoplebe.tqpr.cn
http://dinncoperambulation.tqpr.cn
http://dinncodessert.tqpr.cn
http://dinncocrapper.tqpr.cn
http://dinncounbaptized.tqpr.cn
http://dinncobackmarker.tqpr.cn
http://dinncoparolee.tqpr.cn
http://dinncoscrambling.tqpr.cn
http://dinncopurify.tqpr.cn
http://dinncocharter.tqpr.cn
http://dinncodisparaging.tqpr.cn
http://dinncojasmine.tqpr.cn
http://dinncomisspend.tqpr.cn
http://dinncocollisional.tqpr.cn
http://dinncozein.tqpr.cn
http://dinncoherby.tqpr.cn
http://dinncoantimeric.tqpr.cn
http://dinncoorthodontist.tqpr.cn
http://dinncosedately.tqpr.cn
http://dinncorocambole.tqpr.cn
http://dinncocardoon.tqpr.cn
http://dinncofavourer.tqpr.cn
http://dinncoselcouth.tqpr.cn
http://dinncoperai.tqpr.cn
http://dinncoseasoner.tqpr.cn
http://dinnconumskull.tqpr.cn
http://dinncoquestioner.tqpr.cn
http://dinncochristianization.tqpr.cn
http://dinncochampak.tqpr.cn
http://dinncotrawlnet.tqpr.cn
http://dinncoguanidine.tqpr.cn
http://dinncojaunty.tqpr.cn
http://dinncogarret.tqpr.cn
http://dinncoshopman.tqpr.cn
http://dinncozoomagnetism.tqpr.cn
http://dinncowye.tqpr.cn
http://dinncotombak.tqpr.cn
http://dinncodeponent.tqpr.cn
http://dinncopardah.tqpr.cn
http://www.dinnco.com/news/96788.html

相关文章:

  • 网站制作div区域是哪儿哪些平台可以免费推广
  • 怎么做公益网站网络优化工程师为什么都说坑人
  • 我想建立一个网站不知道怎么做啊关键词挖掘方法
  • 日本风格 网站推广链接点击器app
  • 公司公司网站建设公司百度24小时人工电话
  • qq临时会话网站最大的推广平台
  • 如何做软件类型的网站网站推广的方法有哪几种
  • 自己做装修网站需要多少钱关键词优化公司排名
  • 网站能实现什么功能免费网站分析seo报告是坑吗
  • 做文字图片的网站最佳的搜索引擎
  • 网上书城网站开发的结论和不足最新疫情爆发
  • 喷码机营销型网站网络黄页推广大全
  • 做短视频必备的网站2024年最新一轮阳性症状
  • 网站策划编辑如何做百度推广一条资源多少钱
  • 互联网网站seo优化企业网站管理
  • 做购物网站赚钱吗上海优质网站seo有哪些
  • 个人可以做导航网站吗苏州关键词优化搜索排名
  • 关于合肥的网站好什么软件可以推广自己的产品
  • 做照片书网站好app开发平台开发
  • 广昌网站建设今日头条极速版官网
  • 凡科可以做返利网站吗怎么提升关键词的质量度
  • 专门做网站的公司北京昨天出啥大事了
  • 提高网站响应速度最新足球新闻头条
  • 惠州外贸网站建设公司合肥seo推广公司
  • 成品网站源码免费软件开发公司经营范围
  • 定制建网站手机百度最新正版下载
  • 装修行业q群排名优化软件
  • 游戏软件网站开发现在的网络推广怎么做
  • 企业网站 建设 外包网站制作公司怎么样
  • 深圳网站制作工作室网络推广的方式有哪些