POJ2728最优比率生成树

#include 
#include 
#include 
#include 
using namespace std;

const int NN=1002;
const double inf=1000000000;
const double eps=1e-5;

typedef struct point{
    double x,y,h;
}point;
int n;
point p[NN];
double l,r,mid;
double dis[NN][NN];

void get_dis()
{
    for (int i=1; i<=n; i++)
      for (int j=1; j<=n; j++)
      {
         dis[i][j]=sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y));
         if (dis[i][j]fabs(p[cur].h-p[i].h)-mid*dis[cur][i])
                    lowcost[i]=fabs(p[cur].h-p[i].h)-mid*dis[cur][i];
                if (lowcost[i]eps)
    {
        mid=(l+r)*0.5;
        if (prim()) r=mid;
        else        l=mid;
    }
    printf("%.3f\n",mid);  //我会告诉你因为自作多情在这儿加了ep而WA了好几次么?不懂精度就不要乱搞。。。。。。  
}

int main()
{
    while (scanf("%d",&n),n)
    {
        for (int i=1; i<=n; i++) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].h);
        solve();
    }
    return 0;
}

你可能感兴趣的:(ACM,图论)