最小生成树——解题报告

Linux下离线安装Google Chrome 目录背景一、下载并安装Google Chrome二、下载并安装依赖包1.libvulkan.so.1()(64bit)2.读入数据总结 背景 项目中服务器被要求不能连接外网,不能直接联网安装,所以需要下载Google Chrome安装包和依赖包,然后离线安装。 linux下步骤都一样,不管ubuntu还是centos只是需要下载对应系统的文件包即可。 本机系统:CentOS 7 一、下载并安装Google Chrome 官方下载地址http://www.google.cn/chrome/browser/d 阅读详情

经典prim算法,输出最小生成树,算法思想度娘


/*试用prim算法,输出一个下图的最小生成树。*/
#include<iostream>
#include<vector>
using namespace std;
#define N 100
#define MAXSIZE 1000

vector<int> close(N,MAXSIZE);
int b[N];
int c[N];
int j=0,h=1;

void fun(int a[N][N],int m);


void main()
{
	int m,n,x,y;
	float len;
	int a[N][N];
	cout<<"input m and n:";
	cin>>m>>n;
	for(int h=1;h<=m;h++)
		b[h]=h;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			a[i][j]=MAXSIZE;
		}
	}
	cout<<"input the graph"<<endl;
	for(int k=0;k<n;k++)
	{
		cin>>x>>y>>len;
		a[x][y]=len;
		a[y][x]=len;
	}  
	fun(a,m);
}

void fun(int a[N][N],int m)
{
	
	int n=1;
	while(n<=m)
	{
		c[j]=b[h];
		close[h]=-1;
		for(int i=1;i<=m;i++)
	    {							
			if(a[h][i]<close[i])
			{
				close[i]=a[h][i];
			}
		}
		int min=MAXSIZE;
		for(int k=1;k<=m;k++)
		{
			if(close[k]>0&&close[k]<min)
			{
				min=close[k];
				h=k;
			}			
		}
		j++;
		n++;		
	}
	cout<<"The result is:";
	for(n=0;n<m;n++)
		cout<<c[n]<<" ";
	cout<<endl;
}


 

【eclipse】win 10:eclipse 4.9 下载、安装和汉化(支持中英切换) 目录 一、eclipse下载 二、eclipse安装 三、eclipse在线汉化 四、eclipse离线汉化(推荐) 一、eclipse下载 ①官网下载地址(收费):https://www.eclipse.org/downloads/点击前往下载 ②【推荐】我的百度网盘下载地址(包括离线汉化包):点击下载 提取码:0nfw ③eclipse4.9其他地址下载:http... 阅读详情

相关推荐

C51单片机驱动ILI9341彩屏实战:从Proteus仿真到绘制自定义图案(附完整代码)

本文详细介绍了使用C51单片机驱动ILI9341彩屏的完整实战流程。内容涵盖硬件连接、8080并行接口时序模拟、寄存器初始化、屏幕方向设置以及基本图形绘制原理,并重点讲解了如何在Proteus仿真环境中搭建电路、调试代码,最终实现自定义图案的显示。文章提供了完整的代码示例,为嵌入式开发学习者和复古硬件爱好者提供了一套可行的解决方案。

rnn9storyteller的博客 511

Tyvj2017清北冬令营入学测试

P4744A’s problem(a) 时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试题,每三天结算一次成绩。参与享优惠 描述 这是一道有背景的题目,小A也是一个有故事的人。但可惜的是这里纸张太小,小A无法把故事详细地说给大家听。可能小A自己也讲不清楚自己的故事,因为如果...

weixin_30455067的博客 178

Win10下ISE14.7 iMPACT闪退?三步搞定DLL替换(附详细路径)

本文详细介绍了在Windows 10系统下解决Xilinx ISE14.7 iMPACT工具闪退问题的三步DLL替换方案。通过替换关键DLL文件,有效解决了FPGA开发中的兼容性问题,帮助开发者快速恢复工作流程。

weixin_29290259的博客 586

Day2:T1搜索 T2最小生成树

T1:广搜+判断矩形 注:如何判断搜的是否为矩形: 在广搜的时候,记录下边界的坐标,然后枚举一遍过去,如果搜到"."就是牛群,否则就是房间 瞥了一眼ccy的做法,据说是floodfill的思想(至今不懂是什么?...什么时候补坑吧) 在记录边界的同时+记录同一个连通块的#的个数num,判断num?=(maxx-minx)*(maxy-miny);即可 貌似ccy的做法更科学一点,学习了 ...

weixin_30369087的博客 139

Windows下玩转Spark:零基础本地集群搭建与实战演示

本文详细介绍了在Windows系统下零基础搭建Spark本地集群的完整流程,包括环境准备、集群启动、实战案例演示及性能优化技巧。通过Standalone模式快速部署,结合WordCount等经典案例帮助初学者快速掌握Spark数据处理,特别适合Windows环境下的大数据开发入门学习。

weixin_33734785的博客 425

GXHT40温湿度传感器:I2C通信与CRC校验实战解析

本文详细解析GXHT40温湿度传感器的I2C通信协议与CRC校验机制,涵盖硬件连接、时序控制、数据读取及加热功能应用。通过实战案例分享优化技巧与异常处理,帮助开发者提升嵌入式系统中传感器数据的准确性与可靠性。

rgv234567的博客 242

最小生成树详解(模板 + 例题)

作为一个伪ACMer,先来首广为人知的打油诗: 模拟只会猜题意,贪心只能过样例,数学上来先打表,规律一般是DP,组合数学碰运气,计算几何瞎暴力,图论一顿套模板,数论只会GCD,递归递推伤不起,搜索茫然TLE,分治做得像枚举,暴力枚举数第一,数据结构干瞪眼,怒刷水题找信心。 文章目录1、什么是树2、最小生成树3、最小生成树的应用4、实现最小生成树的两种算法4.1 prim (普里姆算法)4.2 kruskal (克鲁斯卡尔算法)5、总结 1、什么是树 如果一个无向连通图不包含回路(连通图中不存在环),.

潘小蓝的博客 16万+

DDR内存设计必看:DFI接口协议详解与实战避坑指南(附时序图解析)

本文深入解析了DDR内存设计中连接内存控制器与物理层的DFI接口协议,聚焦于DDR4/DDR5设计的实际痛点。文章详细阐述了协议版本兼容性、时钟架构(匹配频率与频率比系统)、PCB信号完整性设计以及上电初始化与调试等关键环节,为硬件工程师提供了一套从理论到实战的完整避坑指南,并附有时序图解析以助理解。

weixin_29256771的博客 331

bzoj 4144 [AMPPZ2014]Petrol 最短路+最小生成树+倍增

Description给定一个n个点、m条边的带权无向图,其中有s个点是加油站。 每辆车都有一个油量上限b,即每次行走距离不能超过b,但在加油站可以补满。 q次询问,每次给出x,y,b,表示出发点是x,终点是y,油量上限为b,且保证x点和y点都是加油站,请回答能否从x走到y。 Input第一行包含三个正整数n,s,m(2<=s<=n<=200000,1<=m<=200000),表示点数、加油站

mars_ch的博客 548

最新Python爬虫实战(入门爬虫篇)——案例18:某气象局全国天气预报数据采集(详细爬虫思路截图 + 抓包动图演示+完整爬虫代码+详细注释)

本次案例针对某气象局天气预报网的静态HTML页面,实现了全国各地区天气数据的全自动化爬取,和之前案例17的动态接口爬虫不同,本次案例聚焦于静态页面的爬虫实现,覆盖了从抓包分析、请求模拟、数据解析到数据存储的完整爬虫流程,非常适合入门学习者巩固基础,核心知识点和实现要点总结如下:首先是页面分析的核心逻辑,静态HTML页面的数据爬取,核心在于通过浏览器开发者工具,完成完整的抓包分析和标签结构定位。

努力让自己发光,对的人才能迎着光而来 27万+

RK AVS双目融合记录

NOTE] 调试平台双目avs融合调试,需要先保证两个摄像头能正常出图同时出流。使用默认工具测试vi->avs->venc通路是否正常,-a可指定isp效果文件需要开启CONFIG_VIDEO_ROCKCHIP_AVSP和CONFIG_VIDEO_ROCKCHIP_FEC,dts中使能。

mangofu的博客 104

BZOJ 4326 NOIP 2015 DAY2 T3 浅谈二分及树上差分数组DFS动态统计

世界真的很大 今天正值全校运动会然而却被困机房 想着写完这道题就下楼看运动会于是乎一A,老天luogu的“大凶”能奈我何? 于是还剩一点时间,所以写一下博客看题先:description: 公元 2044 年,人类进入了宇宙纪元。L 国有 n 个星球,还有 n−1 条双向航道,每条航道建立在两个星球之间,这 n−1 条航道连通了 L 国的所有星球。小 P 掌管一家物流公司, 该公司有很多个

BerryKanry的博客 730

基于STM32L4XX 、HAL库的TMP144YFFR数字温度传感器驱动应用C语言程序设计

define TMP144_ADDRESS 0x00 // 默认为全局地址,用于单器件或MDA命令。#define TMP144_CMD_READ_TEMP 0x00 // 读取温度寄存器命令。if (temp_raw & 0x800) { // 判断第11位(符号位)

PP_Cottage的博客 91

【洛谷P3366】【模板】最小生成树 解题报告

EZ.

Engels_Si_Fish的博客 1277

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

最小生成树问题解题报告

题目一: HDOJ 1879 网址:http://acm.hdu.edu.cn/showproblem.php?pid=1879 问题描述 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低...

Qi的博客 561

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

最小生成树——HDOJ 2988 Dark roads解题报告

Problem Description Economic times these days are tough, even in Byteland. To reduce the operating costs, the government of Byteland has decided to optimize the road lighting. Till now every road was illuminated all night long, which costs 1 Bytelandian Do

plsxysam的专栏 486

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

最小生成树 prim POJ 2349解题报告

Arctic Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13809 Accepted: 4443 Description The Department of National Defence (DND) wishes to connect several northern ou

Dafang_Xu的博客 505

codevs 1078 最小生成树 解题报告

农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,

Hawo11的博客 458

【解题报告】 HDU 1102 Constructing Roads -- 并查集 最小生成树 Prime算法

题目连接:HDU 1102 题目大意:自己看。代码写的很长,主要想练二叉堆来实现优先队列,毕竟学了就得用上。// HDU 1102 Constructing Roads -- 并查集 最小生成树 Prime算法 // 二叉堆 -- 用于优先队列的实现 // 完全二叉树的 I 结点的 两个 child 是 I*2 and I*2+1 . // 完全二叉树的 I 结点的 father 是 I/2

生命有一种绝对 1140

最小生成树 POJ 3625Building Roads解题报告

Building Roads Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 2857 Description Farmer John had just acquired several new farms! He wants to connect the farms

Dafang_Xu的博客 532

解题报告之——hdu1233还是畅通工程(最小生成树)

Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。    Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( 当N为0时,

Reverie 694

洛谷 1195 口袋的天空 最小生成树 解题报告

题目背景小杉坐在教室里,透过口袋一样的窗户看口袋一样的天空。有很多云飘在那里,看起来很漂亮,小杉想摘下那样美的几朵云,做成棉花糖。题目描述给你云朵的个数N,再给你M个关系,表示哪些云朵可以连在一起。现在小杉要把所有云朵连成K个棉花糖,一个棉花糖最少要用掉一朵云,小杉想知道他怎么连,花费的代价最小。输入输出格式输入格式:每组测试数据的第一行有三个数N,M,K(1<=N<=1000,1<=M<=1000

Hawo11的博客 748

最小生成树——HDOJ 1863 畅通工程 解题报告

Problem Description 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。

plsxysam的专栏 426

[kuangbin带你飞]专题六 最小生成树 解题报告

文章目录A - Jungle RoadsB - NetworkingC - Building a Space Station(待补)D - Constructing RoadsE - QS NetworkF - Truck History(待补)G - Arctic NetworkH - HighwaysI - Agri-NetJ - Borg Maze(待补)K - The Unique MST...

chr1stopher 539

codevs 1002 搭桥 【最小生成树】解题报告

有一矩形区域的城市中建筑了若干建筑物,如果某两个单元格有一个点相联系

Hawo11的博客 395

【解题报告】【HDOJ1102】【最小生成树】Constructing Roads

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102 prim最小生成树 1 #include<stdio.h> 2 #include<String.h> 3 #define INF 0x3f3f3f3f 4 int map[105][105]; 5 int set[105]; 6 int su...

weixin_34062329的博客 122
上一篇: 设计一个O(n2)时间的算法,找出由n个数组成的序列的最长单调递增子序列。
下一篇: 回溯法求解0-1背包问题
EmanuelBlog
博客等级 码龄15年 19粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值