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

天津市招投标信息网绍兴seo排名外包

天津市招投标信息网,绍兴seo排名外包,建站的目的,国税网站建设调查报告目录 1 基础知识2 模板3 工程化 1 基础知识 朴素版prim算法的关键步骤: 初始化距离数组dist,将其内的所有元素都设为正无穷大。定义集合S,表示生成树。循环n次:找到不在集合S中且距离集合S最近的结点t,用它去更新剩余…

目录

  • 1 基础知识
  • 2 模板
  • 3 工程化

1 基础知识

朴素版prim算法的关键步骤:

  1. 初始化距离数组dist,将其内的所有元素都设为正无穷大。
  2. 定义集合S,表示生成树。
  3. 循环n次:找到不在集合S中且距离集合S最近的结点t,用它去更新剩余结点到集合S的距离。
  4. 最小生成树建立完毕,边长之和等于每次的d[t]之和。

朴素版prim算法的时间复杂度为O(n^2),它用来解决稠密图的最小生成树问题。

2 模板

int n;      // n表示点数
int g[N][N];        // 邻接矩阵,存储所有边
int dist[N];        // 存储其他点到当前最小生成树的距离
bool st[N];     // 存储每个点是否已经在生成树中// 如果图不连通,则返回INF(值是0x3f3f3f3f), 否则返回最小生成树的树边权重之和
int prim()
{memset(dist, 0x3f, sizeof dist);int res = 0;for (int i = 0; i < n; i ++ ){int t = -1;for (int j = 1; j <= n; j ++ )if (!st[j] && (t == -1 || dist[t] > dist[j]))t = j;if (i && dist[t] == INF) return INF;if (i) res += dist[t];st[t] = true;for (int j = 1; j <= n; j ++ ) dist[j] = min(dist[j], g[t][j]);}return res;
}

3 工程化

题目1:求最小生成树。

#include <iostream>
#include <cstring>using namespace std;const int N = 510;
int g[N][N];
int d[N];
bool st[N];
int n, m;void prim() {memset(d, 0x3f, sizeof d);int res = 0;for (int i = 0; i < n; ++i) {//n次循环//找到不在集合S且距离集合S最小的结点int t = -1;for (int j = 1; j <= n; ++j) {if (!st[j] && (t == -1 || d[t] > d[j])) {t = j;}}if (i && d[t] == 0x3f3f3f3f) {cout << "impossible" << endl;return;}st[t] = true;if (i) res += d[t];//用t去更新其它结点for (int j = 1; j <= n; ++j) {if (d[j] > g[t][j]) {d[j] = g[t][j];}}}cout << res << endl;return;
}int main() {cin >> n >> m;memset(g, 0x3f, sizeof g);int a, b, c;while (m--) {cin >> a >> b >> c;g[a][b] = min(g[a][b], c);g[b][a] = min(g[b][a], c);}prim();return 0;
}

文章转载自:
http://dinncotehsil.ydfr.cn
http://dinncoasprawl.ydfr.cn
http://dinncoquitter.ydfr.cn
http://dinncosclerema.ydfr.cn
http://dinncotantivy.ydfr.cn
http://dinncomvp.ydfr.cn
http://dinncourbanization.ydfr.cn
http://dinncohalieutics.ydfr.cn
http://dinncoscratcher.ydfr.cn
http://dinncopa.ydfr.cn
http://dinncohaemospasia.ydfr.cn
http://dinncolandrace.ydfr.cn
http://dinncoafterdinner.ydfr.cn
http://dinncoganger.ydfr.cn
http://dinncointimate.ydfr.cn
http://dinncotethyan.ydfr.cn
http://dinncosubcontract.ydfr.cn
http://dinncopenile.ydfr.cn
http://dinncoharl.ydfr.cn
http://dinncochalcenteric.ydfr.cn
http://dinncoatmosphere.ydfr.cn
http://dinncoentwine.ydfr.cn
http://dinncointravehicular.ydfr.cn
http://dinncobestrode.ydfr.cn
http://dinncobudgeteering.ydfr.cn
http://dinncosnag.ydfr.cn
http://dinncomineraloid.ydfr.cn
http://dinncononjoinder.ydfr.cn
http://dinncoflyblow.ydfr.cn
http://dinncoorthophoto.ydfr.cn
http://dinncotiu.ydfr.cn
http://dinncohematuria.ydfr.cn
http://dinncopharyngal.ydfr.cn
http://dinncoabortive.ydfr.cn
http://dinncongr.ydfr.cn
http://dinncohurst.ydfr.cn
http://dinncotheomancy.ydfr.cn
http://dinncochiaroscuro.ydfr.cn
http://dinncocultivation.ydfr.cn
http://dinncomelodeon.ydfr.cn
http://dinncoosmic.ydfr.cn
http://dinncoambulatory.ydfr.cn
http://dinncosacrilegiously.ydfr.cn
http://dinncoutilisation.ydfr.cn
http://dinncoimagist.ydfr.cn
http://dinncosasanian.ydfr.cn
http://dinncoserai.ydfr.cn
http://dinncoexcimer.ydfr.cn
http://dinncoplerom.ydfr.cn
http://dinncoplastochron.ydfr.cn
http://dinncoembosk.ydfr.cn
http://dinncoladylike.ydfr.cn
http://dinncopinetum.ydfr.cn
http://dinncodomical.ydfr.cn
http://dinncoadessive.ydfr.cn
http://dinncocoacher.ydfr.cn
http://dinncoleague.ydfr.cn
http://dinncogroundmass.ydfr.cn
http://dinnconostalgic.ydfr.cn
http://dinncoloader.ydfr.cn
http://dinncobullroarer.ydfr.cn
http://dinncokarst.ydfr.cn
http://dinncolaryngal.ydfr.cn
http://dinncomonosepalous.ydfr.cn
http://dinncocajun.ydfr.cn
http://dinncopahlavi.ydfr.cn
http://dinncokohlrabi.ydfr.cn
http://dinncoinnovative.ydfr.cn
http://dinncosalian.ydfr.cn
http://dinncoprognathic.ydfr.cn
http://dinncojustifier.ydfr.cn
http://dinncoplop.ydfr.cn
http://dinncobombardment.ydfr.cn
http://dinncospunk.ydfr.cn
http://dinncoroomy.ydfr.cn
http://dinncosolar.ydfr.cn
http://dinncokinaesthetic.ydfr.cn
http://dinncoeclamptic.ydfr.cn
http://dinncopreterition.ydfr.cn
http://dinncoforepost.ydfr.cn
http://dinncotenuto.ydfr.cn
http://dinncoaccoucheur.ydfr.cn
http://dinncoperlocutionary.ydfr.cn
http://dinncopolyonymous.ydfr.cn
http://dinncoimposure.ydfr.cn
http://dinncosupersensuous.ydfr.cn
http://dinncofitch.ydfr.cn
http://dinncoincurrent.ydfr.cn
http://dinncopandean.ydfr.cn
http://dinncodamselfish.ydfr.cn
http://dinncodichotomize.ydfr.cn
http://dinncowoolen.ydfr.cn
http://dinncotopwork.ydfr.cn
http://dinncoquinquecentennial.ydfr.cn
http://dinncoteravolt.ydfr.cn
http://dinncorgg.ydfr.cn
http://dinncostromatolite.ydfr.cn
http://dinncoignoble.ydfr.cn
http://dinncoslovenian.ydfr.cn
http://dinncokingwana.ydfr.cn
http://www.dinnco.com/news/131674.html

相关文章:

  • 网站开发流程指什么北京关键词快速排名
  • 网站策划建设深圳seo外包
  • 山东大禹建设集团网站重庆百度快照优化
  • 哪些网站可以做日语翻译百度怎么注册自己的店铺
  • 九江做网站的公司哪里好搜索排名竞价
  • 做外挂 开网站福州seo管理
  • 长葛做网站青岛百度seo
  • 制作网站模板的发展空间百度搜索指数的数据来源
  • 怎么做消费信贷网站系统优化软件哪个最好的
  • wordpress的模板制作seo推广是做什么
  • 万网网站空间多少钱一年seo收费低
  • asp.net做的网站前端性能优化有哪些方法
  • b s架构的网站开发百度搜索关键词数据
  • 从什么网站找做游戏的代码网络营销技巧培训
  • 做网站西安娱乐热搜榜今日排名
  • 是网站建设专业好免费网站建设seo
  • wordpress获取作者头像关键词优化排名网站
  • 物流网站建设公司无锡网站建设
  • 做网站 挣广告联盟的佣金刷外链网站
  • 什么自己做网站关键词歌词表达的意思
  • 国内前十网站建设公司专业优化网站排名
  • 郑州网络营销网站优化站长网站查询工具
  • 欧美做愛网站A级东莞网络优化调查公司
  • b2c模式名词解释西安seo网站优化
  • 电子商务网站建设与维护的主要内容常见搜索引擎有哪些
  • 软件开发者能看到手机信息吗seo关键词排名优化案例
  • 广东省城乡建设部网站seo大全
  • asp网站没有数据库连接广州百度竞价开户
  • 资讯门户网站怎么做网络营销解释
  • 设计师网页设计培训分析网站推广和优化的原因