题目大意: https://www.cnblogs.com/forever97/p/3603572.html 讲解:https://www.jianshu.com/p/d40a740a527e 题解:https://www.cnblogs.com/shuaihui520/p/10278840.html #include <bits/stdc++.h> using namespace std; ; int n,m; double f; struct NODE { int v; double w,…
Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 25310   Accepted: 7022 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…
POJ2728 无向图中对每条边i 有两个权值wi 和vi 求一个生成树使得 (w1+w2+...wn-1)/(v1+v2+...+vn-1)最小. 采用二分答案mid的思想. 将边的权值改为 wi-vi*mid. 对所有边求和后除以v 即为 (w1+w2+...wn-1)/(v1+v2+...+vn-1)-mid. 因此,若当前生成树的权值和为0,就找到了答案.否则更改二分上下界. #include<iostream> #include<cstdio> #include<c…
Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 21766   Accepted: 6087 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…
#include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> using namespace std; const int maxn=1005; const double eps=1e-6; const double inf=0xffffffff; struct node{…
/* 迭代法 :204Ms */ #include<stdio.h> #include<string.h> #include<math.h> #define N 1100 #define eps 1e-10 #define inf 0x3fffffff struct node { int u,v,w; }p[N]; double ma[N][N]; double distance(int i,int j) { return sqrt(1.0*(p[i].u-p[j].u…
一个完全图,每两个点之间的cost是海拔差距的绝对值,长度是平面欧式距离, 让你找到一棵生成树,使得树边的的cost的和/距离的和,比例最小 然后就是最优比例生成树,也就是01规划裸题 看这一发:http://blog.csdn.net/sdj222555/article/details/7490797 #include<stdio.h> #include<algorithm> #include<math.h> #include<queue> #includ…
http://poj.org/problem?id=2728 Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 18595   Accepted: 5245 Description David the Great has just become the king of a desert country. To win the respect of his people, he decided to b…
Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 22717   Accepted: 6374 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…
题目大意:给定一个 N 个点的无向完全图,边有两个不同性质的边权,求该无向图的一棵最优比例生成树,使得性质为 A 的边权和比性质为 B 的边权和最小. 题解:要求的答案可以看成是 0-1 分数规划问题,即:选定一个数 mid,每次重新构建边权为 \(a[i]-mid*b[i]\) 的图,再在图上跑一遍最小生成树(这里由于是完全图,应该采用 Prim 算法)判断最小值和给定判定的最小值的关系即可,这里为:若最小值大于 mid,则下界提高,否则上界下降. 代码如下 #include<cmath>…