设为首页 加入收藏

TOP

hdu 4081 Qin Shi Huang's National Road System
2014-11-23 21:27:58 来源: 作者: 【 】 浏览:4
Tags:hdu 4081 Qin Shi Huang' National Road System
大白的345 页。
题目:秦始皇要修一个道路的工程,使得所有城市全部联通。
然后道士徐福可以帮他修一条不需劳动力的路。
给出两个变量:
让这条路的起终点的人口和A
除以除此之外的路的劳动力之和B
秦始皇想让这条路修的位置,使得A/B 最大
思路:
用最小生成树首先生成一个全通图
再用DFS算出每一个城市之间唯一路径上的最大的权值的路
然后枚举每一个城市,用最小生成树计算出的SUM - maxcost[U][V]
#include 
#include 
#include 
#include 
#include 
#define INF 0x3f3f3f3f
#define MAX(a,b) a>b a:b
using namespace std;

struct point
{
    int x,y,p;
}P[1005];

int set[1005];

struct line
{
    int s,e;
    double w;
    bool operator < (const line &cmp)const
    {
        return wminmap[1005];
bool vis[1005];

int find(int x)
{
    while(set[x]!=x)
    x=set[x];
    return x;
}

double dis(point tx,point ty)
{
    return sqrt((double)(tx.x-ty.x)*(tx.x-ty.x)+(double)(tx.y-ty.y)*(tx.y-ty.y));
}


void dfs(int st,int pos)
{
    for(int i=0;ians)ans=tt;
            }
        }
        printf("%.2lf\n",ans);
    }
    return 0;
}


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 1052 Tian Ji -- The Horse R.. 下一篇POJ 3046 Ant Counting 简单DP

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何理解c语言指针和 (2025-12-27 01:19:11)
·为什么C标准库没有链 (2025-12-27 01:19:08)
·玩转C语言和数据结构 (2025-12-27 01:19:05)
·MySQL 基础入门视频 (2025-12-26 23:20:22)
·小白入门:MySQL超详 (2025-12-26 23:20:19)