题目地址:点击打开链接
题意:给你p个基站,s个卫星,卫星不管任何距离都可以连接,无线连接的距离越长,花费越高,求把n个基站连在一起并且花费最小时,无线的最短距离为多少
思路:我的AC代码用C++投会A,用G++投会wrong,我也不知道为啥,组成最小生成树的前s-1条最大边用卫星(至于为啥s个卫星只能替代s-1条边,我也不知道),剩下的用无线
AC代码:
题目地址:点击打开链接
题意:给你p个基站,s个卫星,卫星不管任何距离都可以连接,无线连接的距离越长,花费越高,求把n个基站连在一起并且花费最小时,无线的最短距离为多少
思路:我的AC代码用C++投会A,用G++投会wrong,我也不知道为啥,组成最小生成树的前s-1条最大边用卫星(至于为啥s个卫星只能替代s-1条边,我也不知道),剩下的用无线
AC代码:
kruskal算法,难点在于题目的分析
这个题是自己大概猜测着题意做的,给出有几个频道,两个频道间可
题意:看半个小时的题...大概就是说有n
理解题意之后也并不算太难 大意是给了一些坐标...
图论 最小生成树 kruskal
Description The Department of National Defence (DND)
Prim!/*prim题意:给定一些点,一些卫星,一个卫星能连接两个点,点和点之间通信有一定的距离限制。问能使得所有的点联通的最小距离。*/#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long int64;//typedef __int64 int64;typedef pair PII;#define MP(a,b) make_pair((a),(b)) const int maxn = 505;const int
递归是一种非常重要的算法思想,无论你是前端开发,还是后端开发,都需要掌握它。在日常工作中,统计文件夹大小,解析xml文件等等,都需要用到递归算法。它太基础太重要了,这也是为什么面试的时候,面试官经常让我们手写递归算法。本文呢,将跟大家一起深入挖掘一下递归算法~什么是递归?递归的特点递归与栈的关系递归应用场景递归解题思路leetcode案例分析递归可能存在的问题以及解决方案什么是递归?递归,在计算机
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M