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. 五指cms模版基础

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. aforge之hough

    /// <summary> /// 参数不能是一位索引 /// </summary> /// <param name="bmp"></pa ...

  3. lucene索引的创建与搜索

    package com.cs.multi; import java.io.File;import java.io.IOException; import org.apache.lucene.analy ...

  4. 使用SpringMVC时,配置DispatcherServlet注意的url-pattern的问题

    url-pattern配置时注意: <!--springMVC配置--><servlet> <servlet-name>springMVC</servlet- ...

  5. C# 在word文档中复制表格并粘帖到下一页中

    C# 在word文档中复制表格并粘帖到下一页中 object oMissing = System.Reflection.Missing.Value;            Microsoft.Offi ...

  6. HTTP基础知识

    HTTP是计算机通过网络进行通信的规则,是一种无状态的协议,不建立持久的连接(客户端向服务器发送请求,web服务器返回响应,接着连接就被关闭了): 一个完整的HTTP请求连接,通常有下面7个步骤: 1 ...

  7. jsp标签简介

    一.jsp标签简介 JSP标签也称之为Jsp Action(JSP动作)元素,它用于在Jsp页面中提供业务逻辑功能,避免在JSP页面中直接编写java代码,造成jsp页面难以维护. jsp的常用标签有 ...

  8. POJ 2418 Hardwood Species (哈希,%f 和 %lf)

    我的错因: 本来改用%f输出,我用了%lf,结果编译器直接判定为错误(一部分编译器认为lf是没有错的).当时我还以为是hash出错了.. 方法不止一种: 方法 时间   空间 Hash 891ms 5 ...

  9. Java Web开发: Tomcat中部署项目的三种方法

    web开发,在tomcat中部署项目的方法: 可以参考http://m.blog.csdn.net/blog/u012516903/15741727 定义$CATALINA_HOME指的是Tomcat ...

  10. 用js动态的改变img标签里面的src属性实现图片的循环切换

    JS:根据循环切换的条件可以用 document.getElementById('').src=''设置, 或者jquery方法: $('#id').attr('src','图片名称’): 具体: i ...