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. leetcode——Evaluate Reverse Polish Notation 求算式值(AC)

    Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, ...

  2. 从一开始,说出事java匿名内部类

    java内部类.匿名类原本以为它们的使用已经很滑, 成绩, 就在昨天晚上12指向时钟发生重大事故.事故的严重程度再说吧,那是因为我没有睡一晚睡眠. 那以下先用一段模拟代码来描写叙述下我出现的问题的: ...

  3. 对于COM对象使用ComPtr代替传统指针

    对于COM对象来说使用传统指针比较麻烦,还要记得Release()防止内存泄漏,一不小心就会出现各种各样的问题.针对这种问题微软提供了对于COM对象的智能指针ComPtr,这里是官方文档https:/ ...

  4. RH033读书笔记(15)-Lab 16 The Linux Filesystem

    Lab 16 The Linux Filesystem Goal: Develop a better understanding of Linux filesystem essentials incl ...

  5. zoj 3696 Alien&#39;s Organ(泊松分布)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3696 Alien's Organ Time Limit: 2 S ...

  6. python学习——编码

    为了将各种不同的语言都包括在同一的字符集中,满足国际间的信息交流国际上制定了UNICODE字符集. 通过使用UNICODE字符集能够满足跨语言的文字处理,有效的避免乱码产生. 用法:在脚本中添加下面代 ...

  7. jquery声明

    $("[id^=total_item]")代表 id随着total_item开始XX..必须jquery支持 版权声明:本文博主原创文章,博客,未经同意,不得转载.

  8. ZOJ1463:Brackets Sequence(间隙DP)

    Let us define a regular brackets sequence in the following way: 1. Empty sequence is a regular seque ...

  9. IT该忍者神龟Jquery小工具easyUI物业摘要召回

    找了个时间看了下EasyUI插件.对它的插件感觉是非常舒服,特地把Easy UI的大部分功能属性做了一下汇总. 此属性列表请对比jQuery EasyUI 1.0.5,关于它的很多其它资讯请猛击这里. ...

  10. mongodb.conf

    # mongodb.conf # Where to store the data. dbpath=/var/lib/mongodb #where to log logpath=/var/log/mon ...