Eddy's picture

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 29   Accepted Submission(s) : 26

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

Eddy begins to like painting pictures recently ,he is sure of himself to become a painter.Every day Eddy draws pictures in his small room, and he usually puts out his newest pictures to let his friends appreciate. but the result it can be imagined, the friends are not interested in his picture.Eddy feels very puzzled,in order to change all friends 's view to his technical of painting pictures ,so Eddy creates a problem for the his friends of you.
Problem descriptions as follows: Given you some coordinates pionts on a drawing paper, every point links with the ink with the straight line, causes all points finally to link in the same place. How many distants does your duty discover the shortest length which the ink draws?

Input

The first line contains 0 < n <= 100, the number of point. For each point, a line follows; each following line contains two real numbers indicating the (x,y) coordinates of the point.

Input contains multiple test cases. Process to the end of file.

Output

Your program prints a single real number to two decimal places: the minimum total length of ink lines that can connect all the points. 

Sample Input

3
1.0 1.0
2.0 2.0
2.0 4.0

Sample Output

3.41
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
using namespace std;
const int maxn=;
double mp[maxn][maxn];
double dis[maxn],x[maxn],y[maxn];
int vis[maxn];
int i,j,n,l,k;
double minn,sum; int main()
{
while(~scanf("%d",&n))
{
memset(vis,,sizeof(vis));
for(i=;i<=n;i++) scanf("%lf%lf",&x[i],&y[i]);
for(i=;i<=n;i++)
for(j=i+;j<=n;j++)
{
double d=sqrt(pow(x[i]-x[j],)+pow(y[i]-y[j],));
mp[i][j]=d;
mp[j][i]=d;
}
sum=;
vis[]=;
for(i=;i<=n;i++) dis[i]=mp[][i];
for(i=;i<n;i++)
{
minn=INT_MAX*1.0;
for(j=;j<=n;j++)
if(!vis[j] && minn>dis[j])
{
k=j;
minn=dis[j];
}
vis[k]=;
sum+=minn;
for(j=;j<=n;j++)
if (!vis[j] && dis[j]>mp[k][j])
dis[j]=mp[k][j];
}
printf("%.2lf\n",sum);
}
return ;
}

hdu Eddy's picture (最小生成树)的更多相关文章

  1. HDU 1162 Eddy's picture (最小生成树)(java版)

    Eddy's picture 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1162 ——每天在线,欢迎留言谈论. 题目大意: 给你N个点,求把这N个点 ...

  2. hdu 1162 Eddy's picture (最小生成树)

    Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  3. hdu 1162 Eddy's picture(最小生成树算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1162 Eddy's picture Time Limit: 2000/1000 MS (Java/Ot ...

  4. hdu 1162 Eddy's picture (Kruskal 算法)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1162 Eddy's picture Time Limit: 2000/1000 MS (Java/Ot ...

  5. HDUOJ-----(1162)Eddy's picture(最小生成树)

    Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  6. HDU 1162 Eddy's picture

    坐标之间的距离的方法,prim算法模板. Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32 ...

  7. Eddy's picture(最小生成树)

    Eddy's picture Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...

  8. hdu 1162 Eddy's picture (prim)

    Eddy's pictureTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  9. hdoj 1162 Eddy's picture

    并查集+最小生成树 Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

随机推荐

  1. hadoop---wordcount命令

    [zznu@master file]$ hadoop jar ~/hadoop-2.5.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.2 ...

  2. php 排序

    for($i=1;$i<count($result);$i++) { $tmp = $result[$i]['PNL']; $tmp_ = $result[$i]; $j=$i-1 ; for( ...

  3. HashMap和HashSet的源代码分析

    static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16 static final float DEFAULT_LOAD_ ...

  4. HttpServletRequest对象(一)

    一:HttpServletRequest介绍: 代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中, 二:Request常用的方法 1):获得客户端信 ...

  5. docker中管理数据

    到目前我们介绍了一些Docker的基础概念, 知道了如何使用Docker的image, 也知道了如何在多个container间通过网络通讯. 在这章里我们将介绍如何在docker的container内 ...

  6. STM32F407的串口采用DMA收发数据

    源:STM32F407的串口采用DMA收发数据

  7. 软件测试之α测试和Beta测试

    实施验收测试的常用策略有三种,它们分别是: · 正式验收 · 非正式验收或Alpha 测试 · Beta 测试 因此,Alpha测试和Beta测试都属于验收测试.所谓验收测试是软件产品完成了功能测试和 ...

  8. Android 面试题(转)

    转自:http://www.jobui.com/mianshiti/it/android/2682/ 1. Android dvm的进程和Linux的进程, 应用程序的进程是否为同一个概念DVM指da ...

  9. akka 文章 博客

    http://blog.csdn.net/wsscy2004/article/category/2430395 Actor生命周期理解 Actor生命周期理解 镇图:Actor内功心法图 Actor的 ...

  10. ADT(abstract data types)抽象数据类型

    1.What is it? An abstract data type is a set of objects together with a set of operations. 抽象数据类型是带有 ...