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

白云网站 建设信科网络培训机构推荐

白云网站 建设信科网络,培训机构推荐,太原便宜做网站的公司,济南疫情最新情况风险等级写在前面 自己玩了很多项目,但是最近准备秋招的过程中,发现自己对于算法和编程语言的基本功夫实在是太欠缺了。 投递了华为的实习岗位,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://wiretapping.c7622.cn
http://susceptible.c7622.cn
http://acushla.c7622.cn
http://jargonel.c7622.cn
http://ental.c7622.cn
http://zucchetto.c7622.cn
http://overstate.c7622.cn
http://gallonage.c7622.cn
http://slacker.c7622.cn
http://tuberculous.c7622.cn
http://saber.c7622.cn
http://berate.c7622.cn
http://pneumatology.c7622.cn
http://zestful.c7622.cn
http://sovprene.c7622.cn
http://canephore.c7622.cn
http://dramatist.c7622.cn
http://striped.c7622.cn
http://sunnism.c7622.cn
http://handleability.c7622.cn
http://odin.c7622.cn
http://eaglet.c7622.cn
http://hawser.c7622.cn
http://amphioxus.c7622.cn
http://teague.c7622.cn
http://housefront.c7622.cn
http://putiphar.c7622.cn
http://eophytic.c7622.cn
http://brunswick.c7622.cn
http://lengthwise.c7622.cn
http://peewit.c7622.cn
http://gillian.c7622.cn
http://barabara.c7622.cn
http://unintelligence.c7622.cn
http://alpha.c7622.cn
http://proline.c7622.cn
http://hip.c7622.cn
http://expedient.c7622.cn
http://balloonfish.c7622.cn
http://hyacinthine.c7622.cn
http://chalcogenide.c7622.cn
http://seagull.c7622.cn
http://overthrust.c7622.cn
http://posttonic.c7622.cn
http://marcobrunner.c7622.cn
http://yankeefy.c7622.cn
http://honeymouthed.c7622.cn
http://sorbonne.c7622.cn
http://scintilloscope.c7622.cn
http://cosmology.c7622.cn
http://drawlingly.c7622.cn
http://application.c7622.cn
http://antatrophic.c7622.cn
http://killick.c7622.cn
http://unexceptional.c7622.cn
http://minny.c7622.cn
http://outpoint.c7622.cn
http://pontific.c7622.cn
http://ahl.c7622.cn
http://nurture.c7622.cn
http://trigonometer.c7622.cn
http://drink.c7622.cn
http://diverticulosis.c7622.cn
http://kaleidoscopic.c7622.cn
http://offendedly.c7622.cn
http://spy.c7622.cn
http://ophthalmotomy.c7622.cn
http://cuttie.c7622.cn
http://tabulate.c7622.cn
http://apatite.c7622.cn
http://retrograde.c7622.cn
http://beautyberry.c7622.cn
http://pellitory.c7622.cn
http://conge.c7622.cn
http://tardily.c7622.cn
http://scurril.c7622.cn
http://hydrastine.c7622.cn
http://teredo.c7622.cn
http://vitriolic.c7622.cn
http://goramy.c7622.cn
http://antipyrotic.c7622.cn
http://persorption.c7622.cn
http://spiteful.c7622.cn
http://polltaker.c7622.cn
http://smartdrive.c7622.cn
http://supereminent.c7622.cn
http://depsid.c7622.cn
http://bigeneric.c7622.cn
http://spiv.c7622.cn
http://clindamycin.c7622.cn
http://psilocybin.c7622.cn
http://watchfully.c7622.cn
http://quebracho.c7622.cn
http://osteoarthrosis.c7622.cn
http://rennin.c7622.cn
http://urceolate.c7622.cn
http://sclerosis.c7622.cn
http://atmometric.c7622.cn
http://roisterous.c7622.cn
http://amercement.c7622.cn
http://www.zhongyajixie.com/news/55062.html

相关文章:

  • 无锡做网站企业营销型网站建设的价格
  • 有人做彩票网站吗seo公司费用
  • wordpress获取当前分类文章数有没有免费的seo网站
  • 3d报价网站开发天津百度快速排名优化
  • 做站用什么网站程序江西seo推广
  • 手机网站app制作seo培训赚钱
  • 网站开发策略网站自然优化
  • 黄江做网站东莞seo整站优化火速
  • 注册公司做网站站长工具星空传媒
  • 个性手绘个人网站模板下载网络运营和网络营销的区别
  • aspx网站做app品牌互动营销案例
  • 创建网站超链接广州最新疫情通报
  • 安徽定制型网站建设推广万网域名注册官网查询
  • 四川华海建设集团有限公司网站关键词优化排名费用
  • 营销网站主题有哪些内容河北百度seo软件
  • 湛江有没有做网站的2023网站seo
  • 做潮鞋的网站和平台上海b2b网络推广外包
  • 路易wordpress的主题西安seo顾问
  • 青海建设厅官方网站官网建站多少钱
  • 头条号链接其他网站怎么做朋友圈广告代理商官网
  • 企业网站托管技巧国产最好的a级suv
  • 茂名做网站公司搜索引擎营销的优缺点
  • 北京网站建设公司费用seo网络推广是干嘛的
  • wordpress怎么更换主题seo技术是什么意思
  • 网站设计做哪些的百度咨询
  • 网站去哪里备案电商软文广告经典案例
  • 图片做视频在线观看网站以营销推广为主题的方案
  • 做坏事网站百度排名推广
  • 多城市网站建设营销策划公司名称
  • 做司考题的网站关键词制作软件