Eddy's picture

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

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

这道题也是非常easy的最短路径问题

代码:

#include<stdio.h>

#include<string.h>

#include<math.h>

#define INF 1 << 30

double a[101] , b[101] , map[101][101] ;

double dis[101] ;

int used[101] ;

void prim(int n)

{

 int c = 0 ;

 int i = 0 , j = 0 ;

 double sum = 0 ;

 dis[1] = 0 ;

 for(i = 1 ; i <= n ; i++)

 {

  double min = INF ;

  c = 0 ;

  for(j = 1 ; j <= n ; j++)

  {

         if(!used[j] && dis[j] < min)

   {

    min = dis[j] ;

    c =j ;

   }

  }

  used[c] = 1 ;

  for(j  = 1 ; j <= n ; j++ )

  {

   if(!used[j] && dis[j] > map[c][j])

    dis[j] = map[c][j] ;

  }

 }

 

 for(i = 1 ; i <= n ; i++)

  sum += dis[i] ;

 printf("%.2lf\n",sum);

}

int main()

{

 int n = 0 ;

 while(~scanf("%d",&n))

 {

  memset(a , 0 , sizeof( a ) ) ;

  memset(b , 0 , sizeof( b ) ) ;

  int i = 0 , j = 0 ;

  for(i = 1 ; i <= n ; i++)

  {

   for(j = 1 ; j <= n ; j++)

       map[i][j] = INF ;

   dis[i] = INF ;

   used[i] = 0 ;

  }

  for(i = 1 ; i <= n ; i++)

  {

            scanf("%lf%lf" , &a[i] , &b[i] );

  }

  double m = 0 , x = 0;

  for(i = 1 ; i <= n ; i++ )

  {

            for(j = 1 ; j <= n ; j++)

   {

    x = (a[j]-a[i])*(a[j]-a[i])+(b[j]-b[i])*(b[j]-b[i]) ;

    m = sqrt( x ) ;

    map[i][j] = map[j][i] = m ;

   }

  }

  prim( n );

 }

 return 0 ;

}

杭电1162Eddy&#39;s picture的更多相关文章

  1. 杭电--1162--Eddy's picture--并查集

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

  2. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  3. acm入门 杭电1001题 有关溢出的考虑

    最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...

  4. 杭电acm 1002 大数模板(一)

    从杭电第一题开始A,发现做到1002就不会了,经过几天时间终于A出来了,顺便整理了一下关于大数的东西 其实这是刘汝佳老师在<算法竞赛 经典入门 第二版> 中所讲的模板,代码原封不动写上的, ...

  5. 杭电OJ——1198 Farm Irrigation (并查集)

    畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可 ...

  6. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

  7. C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~

    暑假集训虽然很快乐,偶尔也会比较枯燥,,这个时候就需要自娱自乐... 然后看hdu的排行榜发现,除了一些是虚拟测评机的账号以外,有几个都是AC自动机器人 然后发现有一位作者是用网页填表然后按钮模拟,, ...

  8. 杭电ACM2076--夹角有多大(题目已修改,注意读题)

    杭电ACM2076--夹角有多大(题目已修改,注意读题) http://acm.hdu.edu.cn/showproblem.php?pid=2076 思路很简单.直接贴代码.过程分析有点耗时间. / ...

  9. 杭电ACM2092--整数解

    杭电ACM2092--整数解    分析 http://acm.hdu.edu.cn/showproblem.php?pid=2092 一个YES,一个Yes.试了10几次..我也是无语了..哪里都不 ...

随机推荐

  1. 改动symbol link的owner

    当/home/jenkins文件夹空间不足的时候,能够先查看哪个文件夹在较大的磁盘分区上,然后将jenkins文件夹移动过去 最后创建/home/jenkins link到新位置. 这时候须要改动sy ...

  2. CareerCup chapter 1 Arrays and Strings

    1.Implement an algorithm to determine if a string has all unique characters What if you can not use ...

  3. Android开发经验—不要指望类finalize干活的方法做你想要什么

    之所以专门写了一篇文章finalize方法博客,这是通过在坑的方法引起的.一个读写jni当数据类.我在课堂上finalize该方法被调用来关闭文件和释放内存的方法.频繁调用这个类的时候在JNI里面报异 ...

  4. cocos2d-x -- 渠道SDK【棱镜】接入(1)

    棱镜SDK简单介绍 若想让游戏上线,渠道接入步骤是不可缺少的,为了避免一对一接入渠道问题,我选择了棱镜SDK,由于棱镜是游戏与渠道SDK的中间层,为CP厂商屏蔽各个渠道SDK之间的差异,整个接入过程, ...

  5. 解决无法切换到jenkins用户的问题

    su - jenkins一直有效,今天在centos发现无效,原因是 /etc/password文件里的/bin/bash被yum安装的时候变成了/bin/false. 改动后就能够了. ubuntu ...

  6. IOS应用上传须要做的工作

    苹果开发人员   https://developer.apple.com/ 证书创建流程 certificates (证书): 是电脑可以增加开发人员计划的凭证 证书分为:开发证书和公布(产品)证书, ...

  7. Jeditable 点击编辑文字插件

    Jeditable - jQuery就地编辑插件使用   jeditable是一个jquery插件,它的优点是可以就地编辑,并且提交到服务器处理,是一个不可多得的就地编辑插件.(注: 就地编辑,也有称 ...

  8. 【微信公众平台开发】百度周边搜索接口php封装

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWl2YW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...

  9. Codefoces 432 C. Prime Swaps

    哥德巴赫猜想: 任一大于2的偶数,都可表示成两个素数之和. 任一大于5的整数都可写成三个质数之和. 贪心取尽可能大的素数..... C. Prime Swaps time limit per test ...

  10. metaq spring

    spring metaq spring bean 配置 <bean id="sessionFactory" class="com.taobao.metamorpho ...