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

为什么wa了阿,哪位指点一下阿。。

Posted by 875600 at 2008-03-22 15:46:13 on Problem 3025
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define N 101
#define exp 10e-9
struct Ring{
	float x;
	float y;
	float r;
}ring[N];
int main()
{
	int i,j,ans,num,n;
	double dist;
	while(scanf("%d",&n)&&n!=-1)
	{
		for(i=0; i<n; i++)
		scanf("%f %f %f",&ring[i].x,&ring[i].y,&ring[i].r);
		ans=0;
		for(i=0; i<n; i++)
		{
			num=0;
			for(j=0; j<n; j++)
			{
				if(fabs(ring[i].x-ring[j].x)<exp&&fabs(ring[i].y-ring[j].y)<exp&&fabs(ring[i].r-ring[j].r)<exp)
				{
					num++;
					continue;
				}
				dist=sqrt(pow(ring[i].x-ring[j].x,2)+pow(ring[i].y-ring[j].y,2));
				if(dist>(double)fabs(ring[i].r-ring[j].r)&&dist<fabs(ring[i].r+ring[j].r))
				num++;
			}
			if(num>ans)
			ans=num;
		}
		printf("The largest component contains %d rings\n",ans);
	}
	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