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. C# 语言规范_版本5.0 (第4章 类型)

    1. 类型 C# 语言的类型划分为两大类:值类型 (Value type) 和引用类型 (reference type).值类型和引用类型都可以为泛型类型 (generic type),泛型类型采用一 ...

  2. DigitalOcean VPS简介

    DigitalOcean是一家位于美国的云主机服务商,总部位于美国纽约,成立于2012年.由于价格低廉,高性能配置.灵活布置的优势,近些年来发展迅猛,成为中国站长圈们喜爱的品牌.(访问http://w ...

  3. BJFU 1440 fudq的ACM

    矩阵快速幂 #include<cstdio> #include<algorithm> using namespace std; ; const int INF =1e9; ; ...

  4. input时间输入框小解

    date    年月日 month 年月 week   年周(ios上不可用,android部分会显示当前是第几周) time   时分(ios不显示时/分的字样) datetime 为一输入框,基本 ...

  5. Html的Table与Echart的饼图实现联动效果

    功能描述: 单击Table中的某个单元格,Echart的饼图加载相关的数据,鼠标悬停在Echarts饼图中的某一块中,Table显示与Echarts饼图相关的数据. 例:楼宇经济概要显示每一个季度所有 ...

  6. php中文乱码问题分析及解决办法

    中文乱码问题产生的原因,主要就是字符编码设置问题:             首先,mysql数据库安装的时候字符编码要选择正确,最好选择utf-8比较保险.如果安装时没有设置正确,找到mysql的安装 ...

  7. [笔记]Practical Lessons from Predicting Clicks on Ads at Facebook

    ABSTRACT 这篇paper中作者结合GBDT和LR,取得了很好的效果,比单个模型的效果高出3%.随后作者研究了对整体预测系统产生影响的几个因素,发现Feature+Model的贡献程度最大,而其 ...

  8. php 上传缩放图片

    有时上传图片时因为图片太大了,不仅占用空间,消耗流量,而且影响浏(图片的尺寸大小不一).下面分享一种等比例不失真缩放图片的方法,这样,不管上传的图片尺有多大,都会自动压缩到我们设置尺寸值的范围之内.经 ...

  9. hdu_2842_Chinese Rings(矩阵快速幂)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2842 题意:解开第k个环需要先解开前(k-2)个环,并留有第(k-1)环.问解开n环最少需要几步. 题 ...

  10. string的数值转换

    to_string(val); //数值val的string表示 stoi (s, p, b); stol (s, p, b); stoul (s, p, b); stoll (s, p, b); s ...