摘要:
链接:http://poj.org/problem?id=1789题意:懒得写。思路:要让分式值最大,分母值就要最小。把卡车类型理解为无向网中的顶点,所求最佳方案即为求最小生成树,那个求和就是权值。每两个顶点间边的权值为对应两种卡车编码之间的距离,故先求出邻接矩阵。#include#include#include#include#include#include#includeusing namespace std;const int INF=1000000;const int maxn=2000+5;const int codel=7+2;int n,sumw;int edge[maxn][m 阅读全文
posted @ 2013-06-01 21:26
∑求和
阅读(193)
评论(0)
推荐(0)
摘要:
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=586题意:有n个适配器,不同的适配器价格不同,并给出两个适配器之间如果连接所需的网线价格,要用网线使它们连通,求所需最小费用。思路:计算建立网络的最小费用,是个最小生成树问题。注意在构造有向网时,每条边的权值为网线的价格加上网线所连接的两个适配器的价格。由于只要求最小生成树的权值而不求选择的边,所以把lowcost数组和nearvex数组合并,lowcost[i]=-1仍表示i在集合T内。#include#include#include#include#include# 阅读全文
posted @ 2013-06-01 16:34
∑求和
阅读(300)
评论(0)
推荐(0)
摘要:
n,m表示顶点数和边数。lowcost[]存放顶点集合T'内各顶点到顶点集合T内各顶点权值最小的边的权。nearvex[]记录顶点集合T'内各顶点距离顶点集合T内那个顶点最近。nearvex[i]为-1时,表示顶点i属于集合T.#include#include#include#include#include#include#includeusing namespace std;const int INF=1000000;const int maxn=21;int n,m;int edge[maxn][maxn];int lowcost[maxn];int nearvex[max 阅读全文
posted @ 2013-06-01 12:52
∑求和
阅读(390)
评论(0)
推荐(0)


浙公网安备 33010602011771号