首页 > 其他分享 >Eddy's picture 1162

Eddy's picture 1162

时间:2023-04-20 18:07:29浏览次数:137  
标签:picture his 1162 pictures Eddy 110 include friends


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?


 



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<stdio.h>
#include<string.h>
#include<math.h>
#define mx 0x3f3f3f
int 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;
}


标签:picture,his,1162,pictures,Eddy,110,include,friends
From: https://blog.51cto.com/u_16079508/6210092

相关文章

  • Eddy's digital Roots 1163 (数学+九余数定理)
    Eddy'sdigitalRootsTimeLimit:2000/1000MS(Java/Others)   MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5278   AcceptedSubmission(s):2952ProblemDescriptionThedigitalrootofapositiveintegerisfoundbysumming......
  • kuangbin专题一 简单搜索 起火迷宫(UVA-11624)
    Fire!DescriptionJoeworksinamaze.Unfortunately,portionsofthemazehavecaughtonfire,andtheownerofthemazeneglectedtocreateafireescapeplan.HelpJoeescapethemaze.GivenJoe’slocationinthemazeandwhichsquaresofthemazeareo......
  • HNU2019 Summer Training 3 E. Blurred Pictures
    E.BlurredPicturestimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputDamonlovestotakephotosoftheplaceshevisitsduringhistravels,toputthemintoframes.Allofhisphotosarei......
  • iPicture用户协议
    InordertouseiPictureanditsservices,youshouldreadandabidebythe"iPictureLicenseAgreement"(hereinafterreferredtoas(thisagreement).Aseparateagreementforaservice,andchoosetoacceptornot.Restrictions,disclaimersmay......
  • iPicture隐私政策
    iPicturerespectsandprotectstheprivacyofalluserswhousetheservice.Inordertoprovideyouwithmoreaccurateandpersonalizedservices,iPicturewilluseanddiscloseyourpersonalinformationinaccordancewiththeprovisionsofthisPrivacyP......
  • echarts export three types picture: png、html、svg
    import'./styles.css'importechartsfrom'echarts'import{saveAs}from'file-saver'importJSPDFfrom'jspdf'import{init}from'canvas-to-blob'init(......
  • HDOJ1163 Eddy's digital Roots
    Eddy'sdigitalRootsTimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):7234    AcceptedSubmissio......
  • HDOJ1164 Eddy's research I
    Eddy'sresearchITimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):10709    AcceptedSubmission(......
  • 现代图片性能优化及体验优化指南 - 图片类型及 Picture 标签的使用
    图片资源,在我们的业务中可谓是占据了非常大头的一环,尤其是其对带宽的消耗是十分巨大的。对图片的性能优化及体验优化在今天就显得尤为重要。本文,就将从各个方面阐述,在各种......
  • 每日一道思维题——CF1368C - Even Picture
    题意:给定一整数n,我们给他周围四个格子涂上灰色,要求输出灰色的格子的个数,以及灰色的个数解题思路:我们将n个格子放在一条斜率为1的直线上,他四个方向的格子为灰格子。灰格子......