Eddy's picture 1162
来源:互联网 发布:淘宝假货率 编辑:程序博客网 时间:2024/06/05 17:34
Eddy's picture
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8101 Accepted Submission(s): 4101
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?
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.
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
31.0 1.02.0 2.02.0 4.0
Sample Output
3.41#include<stdio.h>#include<string.h>#include<math.h>#define mx 0x3f3f3fint t,vis[110];double g[110][110];void prim(){int v,i,j,k;double dis[110],min,sum;memset(vis,0,sizeof(vis));for(i=1;i<=t;i++){dis[i]=g[1][i];}dis[1]=0;vis[1]=0;for(v=1;v<t;v++){min=mx;k=1;for(i=1;i<=t;i++){if(!vis[i]&&dis[i]<min){min=dis[i];k=i;}}vis[k]=1;sum+=min;for(i=1;i<=t;i++){if(!vis[i]&&dis[i]>g[k][i])dis[i]=g[k][i];}}sum=0;for(i=2;i<=t;i++)sum+=dis[i];printf("%.2lf\n",sum);return ;}int main(){double x[110],y[110];//这块定义在外面就超时,不知怎么回事... while(scanf("%d",&t)!=EOF){int i,j;for(i=1;i<=t;i++)scanf("%lf%lf",&x[i],&y[i]);for(i=1;i<=t;i++)for(j=1+i;j<=t;j++){g[i][j]=g[j][i]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));}prim();}return 0;}
0 0
- 1162 Eddy's picture
- Eddy's picture 1162
- HDOJ 1162 Eddy's picture
- Hdu-1162 Eddy's picture
- hdu 1162 Eddy's picture
- hdu 1162 Eddy's picture
- hdu 1162 Eddy's picture
- hdu 1162 Eddy's picture
- Hdu 1162 - Eddy's picture
- hdu 1162 Eddy's picture
- HDU 1162 Eddy's picture
- hdu 1162 Eddy's picture
- hdu 1162 Eddy's picture
- HDU 1162 Eddy's picture
- hdu-1162-Eddy's picture
- hdu 1162 Eddy's picture
- hdu 1162 Eddy's picture
- hdu 1162 Eddy's picture
- UINavigationController的代理方法
- hdu 1800 Flying to the Mars 详细题解 哈希
- Struts2+mysql登录验证实例
- activity之间的数据传递方法
- 卷积神经网络(CNN)笔记
- Eddy's picture 1162
- 【二十七】图的遍历--DFS、BFS
- hdu 1102 Constructing Roads(Prime算法)
- Android网络取数据显示到ListView实例
- 大讲台谈Hadoop启动常见的问题及解决方案(一)
- Volley使用时InterruptedIOException,NoConnectionError
- EventBus使用详解(一)——初步使用EventBus
- SVN基本用法
- maven 手动添加jar包到本地仓库和nexus