Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

ac了

Posted by sail6 at 2006-10-10 11:34:09 on Problem 1046
In Reply To:开始害怕会TLE,所也加了一些剪枝条件,结果却是WA,最后直接做却AC Posted by:042622 at 2006-09-10 15:07:18
#include<iostream.h>
#include<math.h>
int main()
{
	double a[16][3];
	int i,j;
	for(i=0;i<16;i++)
	{
		for(j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	double b[3];
	while(cin>>b[0])
	{
		cin>>b[1]>>b[2];
		if(b[0]==-1&&b[1]==-1&&b[2]==-1)break;
		int rem;
		double com=0,check=0;
		rem=0;
		for(j=0;j<3;j++)
			com+=(a[0][j]-b[j])*(a[0][j]-b[j]);
		com=sqrt(com);
		//cout<<com<<endl;
		for(i=1;i<16;i++)
		{
			check=0;
			for(j=0;j<3;j++)
			{
				check+=(b[j]-a[i][j])*(b[j]-a[i][j]);
			}
			check=sqrt(check);
			if(check<com)
			{
				rem=i;
				com=check;
			}
			
		}
		/*//cout<<'(';
		//for(j=0;j<3;j++)
			cout<<b[j]<<',';
		cout<<") maps to (";
		for(j=0;j<3;j++)
			cout<<a[rem][j]<<',';
		cout<<')'<<endl;;*/
		cout<<"("<<b[0]<<","<<b[1]<<","<<b[2]<<") maps to ("<<a[rem][0]<<","<<a[rem][1]<<","<<a[rem][2]<<")"<<endl;














	}
	
	
	
	
	
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator