poj2728(最小比率生成树)】的更多相关文章

用01分数规划 + prime + 二分 竟然2950MS惊险的过了QAQ 前提是在TLE了好几次下过的 = = 题目意思:有n个村庄,村庄在不同坐标和海拔,现在要对所有村庄供水,只要两个村庄之间有一条路即可,建造水管距离为坐标之间的欧几里德距离,费用为海拔之差,现在要求方案使得费用与距离的比值最小,很显然,这个题目是要求一棵最优比率生成树. 解题思路: 对答案进行二分,当把代进去的答案拿来算最小生成树的时候,一旦总路径长度为0,就是需要的答案. 0-1规划是啥? 概念有带权图G, 对于图中每条…
题目大意: 有n个村庄,村庄在不同坐标和海拔,现在要对所有村庄供水, 只要两个村庄之间有一条路即可,建造水管距离为坐标之间的欧几里德距离,费用为海拔之差, 现在要求方案使得费用与距离的比值最小,很显然,这个题目是要求一棵最优比率生成树. ———————————————————————————————————— 这是一道最优比率生成树的题目,是个很明显的0-1分数规划,设每条边代价为ci,距离为di 那么题目要求(∑(ci*xi))/(∑(di*xi))的最小值 xi∈{0,1} 我们进行一波转换…
引用别人的解释: 题意:有n个村庄,村庄在不同坐标和海拔,现在要对所有村庄供水,只要两个村庄之间有一条路即可, 建造水管距离为坐标之间的欧几里德距离(好象是叫欧几里德距离吧),费用为海拔之差 现在要求方案使得费用与距离的比值最小 很显然,这个题目是要求一棵最优比率生成树, 概念 有带权图G, 对于图中每条边e[i], 都有benifit[i](收入)和cost[i](花费), 我们要求的是一棵生成树T, 它使得 ∑(benifit[i]) / ∑(cost[i]), i∈T 最大(或最小). 这…
poj2728 题意 给出 n 个点的坐标和它的高度,求一颗生成树使得树上所连边的两点高度差之和除以距离之和最小. 分析 01分数规划+最小生成树. 对于所有的边,在求最小生成树过程中有选或不选的问题, 首先根据01分数规划,我们要使 $ l = \frac{\sum_{i=1}^{n} height[i] * exist[i]}{\sum_{i=1}^{n} dis[i] * exist[i]}$ (exist[i]表示是否有这条边)最小, 设 \(F(l) = {\sum height[i]…
Description David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his country to bring water to every village. Villages which are connected to his capital village will be…
以下内容均为转载 http://www.cnblogs.com/ftae/p/6947497.html poj2728(最小比率生成树)   poj2728 题意 给出 n 个点的坐标和它的高度,求一颗生成树使得树上所连边的两点高度差之和除以距离之和最小. 分析 01分数规划+最小生成树. 对于所有的边,在求最小生成树过程中有选或不选的问题, 首先根据01分数规划,我们要使 l=∑i=1nheight[i]∗exist[i]∑i=1ndis[i]∗exist[i] (exist[i]表示是否有这…
POJ2728 Desert King Description David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his country to bring water to every village. Villages which are connected to his cap…
Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 28407   Accepted: 7863 Description David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his coun…
最优比率生成树教程见http://blog.csdn.net/sdj222555/article/details/7490797 个人觉得很明白易懂,但他写的代码略囧. 模板题,但是必须Prim,不能用Kruscal,因为是完全图 Code: #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; ]; int n; ]; ][],…
题目描述: David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his country to bring water to every village. Villages which are connected to his capital village will be water…