# Eddy's picture

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6821    Accepted Submission(s): 3444

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

Author

eddy

``` 1 #include<cstdio>
2 #include<cstring>
3 #include<cmath>
4 #include<algorithm>
5 using namespace std;
6 const int inf=0x3f3f3f3f;
7 const int maxn=105;
8 double map[maxn][maxn];
9 double lowc[maxn];
10 bool vis[maxn];
11 struct point{
12
13   double x,y;
14   int id;
15 };
16
17 inline double dista(point a,point b){
18   return sqrt((a.y-b.y)*(a.y-b.y)+(a.x-b.x)*(a.x-b.x));
19 }
20
21 point sac[maxn];
22
23 double prim(int st,int n)
24 {
25     memset(vis,0,sizeof(vis));
26     vis[st]=true;
27     double minc=inf;
28     for(int i=1;i<=n;i++)
29         lowc[i]=map[st][i];
30     int pre=st;
31     double sum=0.0;
32     for(int i=1;i<n;i++){
33         minc=inf;
34         for(int j=1;j<=n;j++)
35         {
36             if(!vis[j]&&minc>lowc[j]){
37                 minc=lowc[j];
38                 pre=j;
39             }
40         }
41          sum+=minc;
42          vis[pre]=true;
43         for(int j=1;j<=n;j++){
44             if(!vis[j]&&lowc[j]>map[pre][j]){
45                 lowc[j]=map[pre][j];
46             }
47         }
48     }
49     return sum;
50 }
51 void work(int n)
52 {
53     for(int i=0;i<n;i++){
54         for(int j=0;j<n;j++){
55           map[i+1][j+1]=map[j+1][i+1]=dista(sac[i],sac[j]);
56         }
57     }
58 }
59 int  main(){
60    int n;
61    while(scanf("%d",&n)!=EOF){
62
63       for(int i=0;i<n;i++)
64       {
65         scanf("%lf%lf",&sac[i].x,&sac[i].y);
66         sac[i].id=i+1;
67       }
68      work(n);
69      printf("%.2lf\n",prim(1,n));
70    }
71    return 0;
72 }```

0 条评论

## 相关文章

### HDU 1017 A Mathematical Curiosity【水，坑】

A Mathematical Curiosity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit:...

2704

### HDUOJ------1058 Humble Numbers

Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/327...

3538

### Ignatius and the Princess II

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth...

1252

### HDUOJ---3371Connect the Cities

Connect the Cities Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768...

3277

### hdu------（3549）Flow Problem（最大流（水体））

Flow Problem Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 65535/32768...

3477

### HDUOJ---Can you solve this equation?

Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Li...

2858

### HDUOJ---kiki's game

kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K...

3228

### HDU 2147 kiki's game(规律，博弈)

kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 ...

2846

### HDOJ 1004

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 655...

1978

### HDUOJ----1170Milk

Milk Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java...

27810